...

View Full Version : Need Help with Forms & JavaScript!!



helpplease
07-24-2002, 05:33 PM
Hi, here's what I'm hoping someone can help me with:
I have a form that has a couple radio buttons that people can chose from. What I need is a script that determines which radio button is chosen and then when the user clicks on the "next" button, the site will go on to appropriate html page. So I have 7 radio buttons and 7 subsequent webpages that depending on which radio button is chosen, the user will go to that specific webpage.
Thanks for any help!

msimmons
07-24-2002, 05:45 PM
What I would suggest in this case is to put the URL in the value of the radio. Then on submit put that value in a location.href.

Hope that points you in the right direction,
Michael

helpplease
07-24-2002, 05:48 PM
I'm not sure what you mean by "put that value in a location.href"??

adios
07-24-2002, 06:10 PM
<html>
<head>
<title>untitled</title>
<script type="text/javascript" language="JavaScript">

function gotoURL(form) {
var radGrp = form.URL;
for (var i=0; i<radGrp.length; i++)
if (radGrp[i].checked) {
location = radGrp[i].value; return;
}
alert('Please choose one of the websites on the list.');
}

</script>
</head>
<body>
<form>
<input name="temp" type="hidden">
<input name="URL" type="radio" value="javascript&#58;alert('URL 1')"> URL 1<br>
<input name="URL" type="radio" value="javascript&#58;alert('URL 2')"> URL 2<br>
<input name="URL" type="radio" value="javascript&#58;alert('URL 3')"> URL 3<br>
<input name="URL" type="radio" value="javascript&#58;alert('URL 4')"> URL 4<br>
<input name="URL" type="radio" value="javascript&#58;alert('URL 5')"> URL 5<br>
<input name="URL" type="radio" value="javascript&#58;alert('URL 6')"> URL 6<br>
<input name="URL" type="radio" value="javascript&#58;alert('URL 7')"> URL 7<br><br>
<input type="button" value="Go To Site" onclick="gotoURL(this.form)">
</form>
</body>
</html>

Just replace the values with real URLs.

helpplease
07-24-2002, 06:12 PM
Thanks so much!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum