hii I have a 2 radio button in first.html So i want to get the selected radio button value using DOM APIs. without getElementById is preferable for me bcoz i am using node.type=="radio" can anyone help me out??
Hi, in case you have radio as following : <input type="radio" name="yesno" value="yes" /><input type="radio" name="yesno" value="no" /> You just go through all radios (in case of only two radios, you can just check if the first is checked) : var l = your_form.yesno.length; for(var i=0; i<l; i++) if(your_form.yesno.checked) var radio_value = your_form.yesno.value Where 'your_form' is the reference to the form, where the radio is Hope it helps
Please checkout i just want to get the selected value of the radio button. <script language="javascript"> function ViewPopup(){ myWindow=window.open('','','width=400,height=200'); var table =document.getElementById("myTab"); var cells = table.getElementsByTagName("td"); for (var i = 0; i < cells.length; i++) { node=cells.firstChild; // Here is problem if(node.type=="radio"){ if (cells.checked=true){ myWindow.document.writeln(node.getAttribute("value")+"<br/>"); } } } myWindow.focus() } </script> <body> <table id="myTab" width="200" border="1"> <tr> <td colspan="2"> <input type="button" name="btn" value="Data" onclick="ViewPopup()"/> </td> </tr> <tr> <td colspan="2"> <input type="radio" name="marital" value="single" id="marital_single" /> Single<br /> <input type="radio" name="marital" value="divorced" id="marital_divorced" /> Divorced</td> </tr> </table> </body>