You need to sign in to do that
Don't have an account?

Syntax Error getting value from the radio button
Please help me to figure out how to get value for checked radio, I am getting message:syntax error
========================================================
<html>
<head>
<script language="javascript" src="/soap/ajax/9.0/connection.js"></script>
<script language="javascript">
<!--
<head>
<script language="javascript" src="/soap/ajax/9.0/connection.js"></script>
<script language="javascript">
<!--
function do_code() {
r1=document.getElementById("radio").elements[0].value;
r2=document.getElementById("radio").elements[1].value;
alert(r1);
alert(r2);
}
//-->
</script>
<table border="0" width="100%">
<tr>
<td align="center">Primary Distributor<input id="radio" name="radio" type="radio" value="pd" /> </td>
<td>Secondary Distributor<input id="radio" name="radio" type="radio" value="sd" /> </td>
</tr>
<hr>
<tr>
<td>
<input type="button" name="btnSearch" value="Search" id="btnSearch" onclick="do_code()">
</td>
</tr>
</table>
</html>
</body>

I believe you want ("radio").elements[0].checked;
Code:
You shouldn't give radio options the same id. You best query em by name