Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple radio button Code not working

Status
Not open for further replies.

charan1976

Programmer
Aug 5, 2002
4
0
0
US
Hi,
I have 2 radio buttons and a checkbox. The user cannot choose radio button 1 and the checkbox at the same time. For that, I have to prompt an alert. But it doesn't work. Please help.

Code -
****************************
<HEAD>
<SCRIPT Language=JavaScript>

function validateMulti(form2)
{
if (form2.multiRound.value == 0 && form2.checkBox1.value == &quot;true&quot;) {
alert(&quot;You have selected Multiple Order with Leg delivery. Choose only one option.&quot;);
return false;
}
}
</SCRIPT>
</HEAD>
<BODY>
<FORM ACTION=&quot;Order_Sub_Process.asp&quot; METHOD=&quot;post&quot; ID=form2 NAME=form2>

Check for
Multiple Orders <INPUT id=&quot;checkbox1&quot; type=checkbox name=&quot;multiOrder&quot; value=&quot;true&quot;><BR>
<INPUT type=radio name=&quot;multiRound&quot; id=&quot;multiRound&quot; value=0>Multi-Leg<BR>
<input type=radio name=&quot;multiRound&quot; id=&quot;multiRound&quot; value=1>Round Trip<BR>

<INPUT TYPE=submit NAME=submit2 ID=submit2 VALUE=&quot;Continue&quot; style=&quot;FONT-FAMILY: sans-serif&quot; onClick=&quot;validateMulti(form2)&quot;>
</FORM>
</BODY>
**************************************
Please help.
Thanks in Advance
Sankar Bhamidi.
 
charan,
I would change the names of the multiround button to mulitround1 & 2. Then you can check for the .checked property of these controls.
function validateMulti(form2)
{
if (form2.multiRound1.checked==true && form2.checkBox1.checked==true) {
alert(&quot;You have selected Multiple Order with Leg delivery. Choose only one option.&quot;);
return false;
}
}
</SCRIPT>
</HEAD>
good luck,

tsmith
<BODY>
<FORM ACTION=&quot;Order_Sub_Process.asp&quot; METHOD=&quot;post&quot; ID=form2 NAME=form2>

Check for
Multiple Orders <INPUT id=&quot;checkbox1&quot; type=checkbox name=&quot;multiOrder&quot; value=&quot;true&quot;><BR>
<INPUT type=radio name=&quot;multiRound1&quot; id=&quot;multiRound&quot; value=0>Multi-Leg<BR>
<input type=radio name=&quot;multiRound2&quot; id=&quot;multiRound&quot; value=1>Round Trip<BR>

<INPUT TYPE=submit NAME=submit2 ID=submit2 VALUE=&quot;Continue&quot; style=&quot;FONT-FAMILY: sans-serif&quot;
onClick=&quot;validateMulti(form2)&quot;>
</FORM>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top