javascript - How to confirm if a radiobox is checked -



javascript - How to confirm if a radiobox is checked -

*currently want check if radiobox checked using html , javascript only. when click radio buttons, want javascript alert message pop saying particular button has been clicked, nil comes up. able rectify errors have

function checked() { if(document.getelementbyid("s1").checked) { alert("small"); } if(document.getelementbyid("s2").checked) { alert("medium"); } if(document.getelementbyid("s3").checked) { alert("large"); } if(document.getelementbyid("s4").checked) { alert("extra large"); } } <input type="radio" id="s1" name="shirtsize" value="small" onchange="checked()"/>small <input type="radio" id="s2" name="shirtsize" value="medium" onchange="checked()"/>medium <input type="radio" id="s3" name="shirtsize" value="large" onchange="checked()"/>large <input type="radio" id="s4" name="shirtsize" value="extralarge" onchange="checked()"/>extra big

your input appreciated*

change function name radio_checked() checked() checked reserved keyword , cause error!

mark goes here:

<input type="radio" id="s1" name="shirtsize" value="small" onchange="radio_checked()"/>small

script

function radio_checked() { // ......... rest of code ......... } demo

you getting error because checked property checkboxes , radio buttons , you're creating user defined function same name i.e. checked() cost errors, rest of code not execute.

javascript html

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -