php_novice2007 Posted August 17, 2007 Share Posted August 17, 2007 Hi, I have the following code: <table><tr> <td><input type=radio name="AnimationChoice" checked value="u0001">u0001</td> <td><input type=radio name="AnimationChoice" checked value="u0002">u0002</td> <td><input type=radio name="AnimationChoice" checked value="u0015">u0015</td> </tr></table> <input id="animatePath" type="button" onclick="startAnimation();" value="Animate Path!"> function startAnimation(){ var r = document.getElementById("AnimationChoice"); var counter; for (counter = 0; counter < r.length; counter++) { if (r[counter].checked) { alert(r[counter].value); break; } } document.getElementById("animatePath").style.display = 'none'; animatePath(r[counter].value); } First I want to find out which radio button is selected. In FF I'm getting the error which says "r has no properties", and in IE I don't get any error at all, but no alert box either Can anyone help? Thanks in advance~! Quote Link to comment Share on other sites More sharing options...
adam84 Posted August 17, 2007 Share Posted August 17, 2007 1. try this to check if your radio button is selected var r = document.getElementById("AnimationChoice"); var counter; for (counter = 0; counter < r.options.length; counter++) { if (r.options[counter].selected ) { alert(r.options[counter].value); break; } } 2. Something I found by putting id instead of name, it solved the problem. No 100% sure, try it <td><input type=radio id="AnimationChoice" checked value="u0001">u0001</td> <td><input type=radio id="AnimationChoice" checked value="u0002">u0002</td> <td><input type=radio id="AnimationChoice" checked value="u0015">u0015</td> Quote Link to comment Share on other sites More sharing options...
php_novice2007 Posted August 18, 2007 Author Share Posted August 18, 2007 This doesn't work It says option.0 is null or not an object. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.