my code doesn't work. undefined is displayed.....h ow to get a value of radoi button in javascript
[HTML]function enableaddr()
{
alert(document. getElementById( 'reason').lengt h);
for (var i=0; i < document.getEle mentById('reaso n').length; i++)
{
if (document.getEl ementById('reas on[i]').checked)
{
var reason1 = document.getEle mentById('reaso n[i]').value;
alert(reason1);
}
}
}
<form action="cust_in dex.php?action= delete&cid=<?ph p echo $cid;?>" name="del_form" >
<table width="400" border="0" cellpadding="6" align="center" cellspacing="1" class="bg1">
<tr class="bg2"><td >Enter the reason to delete the record with the customer name <?php echo $name;?> :</td></tr>
<tr class="bg2"><td ><input type="radio" name="reason" id="reason" value="close" onclick="enable addr()" />Close</td></tr>
<tr class="bg2"><td ><input type="radio" name="reason" id="reason" value="shifta" onclick="enable addr()" />Shift </td></tr>
<tr class="bg2"><td >Enter the address : &n bsp;<textarea cols="30" rows="4" disabled="disab led" name="shiftaddr ess" id="shiftaddres s"></textarea></td></tr>
<tr class="bg2"><td align="center"> <input type="submit" value="submit" class="button"> </td></tr>
<input type="hidden" name="reason1" id="reason1" />
</table>
</form>[/HTML]
[HTML]function enableaddr()
{
alert(document. getElementById( 'reason').lengt h);
for (var i=0; i < document.getEle mentById('reaso n').length; i++)
{
if (document.getEl ementById('reas on[i]').checked)
{
var reason1 = document.getEle mentById('reaso n[i]').value;
alert(reason1);
}
}
}
<form action="cust_in dex.php?action= delete&cid=<?ph p echo $cid;?>" name="del_form" >
<table width="400" border="0" cellpadding="6" align="center" cellspacing="1" class="bg1">
<tr class="bg2"><td >Enter the reason to delete the record with the customer name <?php echo $name;?> :</td></tr>
<tr class="bg2"><td ><input type="radio" name="reason" id="reason" value="close" onclick="enable addr()" />Close</td></tr>
<tr class="bg2"><td ><input type="radio" name="reason" id="reason" value="shifta" onclick="enable addr()" />Shift </td></tr>
<tr class="bg2"><td >Enter the address : &n bsp;<textarea cols="30" rows="4" disabled="disab led" name="shiftaddr ess" id="shiftaddres s"></textarea></td></tr>
<tr class="bg2"><td align="center"> <input type="submit" value="submit" class="button"> </td></tr>
<input type="hidden" name="reason1" id="reason1" />
</table>
</form>[/HTML]
Comment