Forums

This topic is locked

Switch is not working

Posted 21 Apr 2006 18:47:15
1
has voted
21 Apr 2006 18:47:15 Carol Maurer posted:
Can anyone tell me what I am doing wrong. I've two problems with this code. First it is not recognizing the variable so it always goes to default. Secondly after getting a message to choose on of the radio buttons it goes to a page can't be found. These pages are in the same folder on the site.
<pre id=code><font face=courier size=2 id=code>
function onaccept(form2)
{
term=document.form2.accept.value
switch (term) {
case "1":
document.URL = "membershipform.php";
break;
case "2":
document.URL = "membershipform.php";
break;
case "3":
alert("Sorry, but we cannot proceed with your request for membership if you do not accept our terms.";
document.URL = "membership.html";
break;
default:
alert("Please select an Acceptance of Terms";
document.URL = "membershipterms.html";
}
}

</font id=code></pre id=code>

Replies

Replied 28 Apr 2006 15:08:34
28 Apr 2006 15:08:34 Patrick Woldberg replied:
First I would suggest not to use term=document.form2.accept.value but something like term=document.getElementById("accept".value which works in all browsers. You must add an id to the element named accept.

For the url you have to use the full web url, not only the page

--------------------------------------------------
Patrick Woldberg
Web Developer at Dynamic Zones
Administrator at DMXzone.com, FLzone.net, FWzone.net and DNzone.com
--------------------------------------------------

Reply to this topic