Cod-nes Posted August 2, 2010 Share Posted August 2, 2010 I'm trying to get the value for radios using JavaScript but I keep getting undefined values. >.< What am I doing wrong? function checka() { var a = document.seaform.searadx; alert(a);} <form name="seaform" action="java script: msgsea()" method="get"> <div style="margin-bottom:4px;">Search for username: <input type="text" id="search" maxlength="12" size="12" onkeyup="msgsea()"> <a href="java script: msgsea();">Search</a> <br> That begins with the keyword: <input type="radio" name="searadx" value="begins" checked="checked"><br> That contains the keyword: <input type="radio" name="searadx" value="contains"><br> That ends with the keyword: <input type="radio" name="searadx" value="ends"> <a href="java script:checka()">Test Value</a> </div></form> Link to comment Share on other sites More sharing options...
ShadowMage Posted August 2, 2010 Share Posted August 2, 2010 I don't recommend doing this with dot notation, but try this:var a = document.seaform.searadx.value;If you're interested in modernizing this code you should look up the getElementsByName function and use that to populate an array, which you would then loop through to see which radio is checked and return its value. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.