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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Radio Buttons Don't Redirect Properly

Status
Not open for further replies.

scripter73

Programmer
Apr 18, 2001
421
US
Hi,

I know this is a textbook question, but I'm still having problems with it.

Goal. I have 4 radio buttons. I want my script to function so that when the user clicks on Button 1 and clicks Redirect button, they're redirected to Form4.html, Button 2(=Form6.html); Button 3(=Form7.html); Button 4(=complete.html).

Ideally, I would like the page to redirect automatically as soon as the user clicks the button, but my user doesn't want that. They want to make the selection and click a 'Continue-like' button.

Here's the problem. No matter what the user selects, it always goes to the first button entry. When you click the button to continue processing, you notice the first button gets checked again.

If you'd like to take a look at the functionality, I have it out on
For debugging purposes, I have 2 buttons called Show Checked and Redirect. If you make a selection, and click Show Checked, it will show you the actual value. If you click Redirect, it should attempt to redirect you. It does, but to the same 1st page.

Hope this is clear. Any help is appreciated.

Oh, here's the code (I have a little JS mixed in too):


<html>
<head>
<title>Claims - Form 3</title>

<script language=&quot;Javascript&quot;>

function process_redirect(){

if (document.form3.addinfo[0].checked = true)
window.location.href=&quot;form4.html&quot;;

else if (document.form3.addinfo[1].checked = true)
window.location.href=&quot;form6.html&quot;;

else if (document.form3.addinfo[2].checked = true)
window.location.href=&quot;form7.html&quot;;

else if (document.form3.addinfo[3].checked = true)
window.location.href=&quot;complete.html&quot;;


return;

}

function show_checked(){

if (document.form3.addinfo[0].checked = true)
document.write(document.form3.addinfo[0].value);

else if (document.form3.addinfo[1].checked = true)
document.write(document.form3.addinfo[1].value);

else if (document.form3.addinfo[2].checked = true)
document.write(document.form3.addinfo[2].value);

else if (document.form3.addinfo[3].checked = true)
document.write(document.form3.addinfo[3].value);

}


</script>
</head>

<body>
<form action=&quot;&quot; name=&quot;form3&quot; method=&quot;post&quot;>
<font face=&quot;Verdana, Arial, Sans-Serif&quot; size=1 color=&quot;#083194&quot;>
<table cellpadding=0 cellspacing=0 width=600 border=0>
<tr>
<td width=600 colspan=2>
<font face=&quot;Verdana, Arial, Sans-Serif&quot; size=3 color=&quot;#083194&quot;>
</font>
</td>
</tr>
<tr>
<td width=600 colspan=2><hr></td>
</tr>
</table>
<font size=2>
<input type=&quot;radio&quot; name=&quot;addinfo&quot; value=&quot;another_vehicle&quot;>
Check here to add information about <font color=&quot;red&quot;>Another Vehicle</font> that was involved.<br><br>
<input type=&quot;radio&quot; name=&quot;addinfo&quot; value=&quot;property&quot;>Check here to add information about
<font color=&quot;red&quot;>Property</font> that was damaged.<br><br>
<input type=&quot;radio&quot; name=&quot;addinfo&quot; value=&quot;pedestrian&quot;>Check here to add information about a
<font color=&quot;red&quot;>Pedestrian</font> that was injured.<br><br>
<input type=&quot;radio&quot; name=&quot;addinfo&quot; value=&quot;completed_report&quot;>Check here if your report
is <font color=&quot;red&quot;>Complete</font>.<br><br>
<input type=&quot;button&quot; value=&quot;Show Checked&quot; name=&quot;Form3_Show Checked&quot; onclick=&quot;show_checked()&quot;;>
<input type=&quot;button&quot; value=&quot;Redirect&quot; name=&quot;Form3_Redirect&quot; onclick=&quot;process_redirect()&quot;;>
<input type=&quot;reset&quot; value=&quot;Reset&quot; name=&quot;Form3_Reset&quot;>
</font>
</form>
</body>
</html>



Thanks,
scripter73
 
your if statements are wrong. Instead of one = there shouild be two for checking the equality. Somehting like this

if (document.form3.addinfo[0].checked == true)

That should work

;-)
 
Thanks nitinkhanna!

That worked like a charm. I hate it when I can't figure those out! I'm glad it was a simple fix, though.

Thanks again!

scripter73
 
That's a common error in javascript and perl both, and a difficult one to debug. I STILL do it every now and then, and I've been doing perl for about 8 years!
Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top