|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
HI, we are trying to create a form where if you enter a certain country, say candada it takes you to one page when you submit the form..and if you pick U.S.A. then it takes you to another form ...Is this going to have to involve java, or is there any way to use a variables within html?
|
|
#2
|
|||
|
|||
|
Hi Kimberly,
It's a little complicated, but try this: <HTML> <HEAD> <SCRIPT LANGUAGE='javascript'> function direct (frm) { switch (frm.Country.selectedIndex) { case 0: frm.action="canada.html"; break; case 1: frm.action="us.html"; break; } return true; } </SCRIPT> </HEAD> <BODY> <FORM onSubmit="return direct(this);"> <SELECT NAME="Country"> <OPTION>Canada</OPTION> <OPTION>United States</OPTION> </SELECT> <INPUT TYPE=submit VALUE="Enter"> </FORM> </BODY> </HTML> Let me know how this goes. -- Christopher |
|
#3
|
|||
|
|||
|
Incidentally, if you want the page to change as soon as the user select a country (without having to click "Submit"), the code would look like this:
<HTML> <HEAD> <SCRIPT LANGUAGE="javascript"> function direct (slct) { switch (slct.selectedIndex) { case 0: self.document.location.href="canada.html"; break; case 1: self.document.location.href="us.html"; break; } } </SCRIPT> </HEAD> <BODY> <FORM> <SELECT NAME="Country" onChange="direct(this);"> <OPTION>Canada</OPTION> <OPTION>United States</OPTION> </SELECT> </FORM> </BODY> </HTML> Naturally, replace canada.html with the page that you want for Canada and replace us.html with the page that you want for the U.S. -- Christopher (I hope this works) |
![]() |
| Viewing: Dev Shed Forums > Web Design > HTML Programming > forms--redirecting to different pages |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|