Click to See Complete Forum and Search --> : pass value from radio button


leeky83
03-01-2004, 03:37 AM
who know how to pass the value of radio button in javascript...
i only received "undefined" value...

David Harrison
03-01-2004, 04:49 AM
You can do this:

var rad=document.the_form.the_name;
var val;

for(var n=0;n<rad.length;n++){
if(rad[n].checked){break;}
}

if(n<rad.length){val=rad[n].value;}

If there is a radio button checked in a that specific group then the val variable will contain it's value, if not then the variable will have a null value.