Hi
One of my friend, asked with me, how to select the value of html radio button list using Javascript ?
In html radio button list, we can select the value like this
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> <script type="text/jscript"> function getResults() { var radios = document.getElementsByName("group1"); for (var i = 0; i < radios.length; i++) { if (radios[i].checked) { alert(radios[i].value); break; } } // if (radios[0].checked) { // alert('Male'); // } // else { // alert('Female'); // } } </script> </head> <body> <input type="radio" value="Male" id="radio1" name="group1" /> Male <input type="radio" value="Female" id="radio2" name="group1" /> Female <br /> <br /> <input type="button" id="btnClik" value="Click Here" onclick="getResults();" /> </body> </html>
Good blog! I truly love how it is simple to read. I’m curious how I could be notified whenever a new article has been created. I’ve subscribed to your RSS which
should do! Have a great day and please excuse my bad english!
You are welcome. Thanks for posting your kind and soft feedback. You can follow my blog. if i will post any artical then you will get the email.