|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hello, Im writing a tiny webpage which will re-direct visitor to another page according to the data he entered.
I cannot get it work. Pls help. here is my code: <HTML> <SCRIPT LANGUAGE="JavaScript"> function newurl() { if (document.search.form_boy.value != "" ){ window.location = "boy.html"; } if (document.search.form_girl.value != "" ){ window.location = "girl.html"; } } </SCRIPT> <head> <title>test</title> </head> <body> <form name="search" action="search.html" method="post" onsubmit="return newurl()"> Enter a boy name:<input type="text" name="form_boy" size="20" value=""><br> or<br> Enter a Girl name<input type="text" name="form_girl" size="20" value=""><br> <input type="submit" value=" Submit "> </form> </HTML> |
|
#2
|
|||
|
|||
|
Use this code. It works. You have the right idea, but some of the syntax is messed up. Good luck.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <title>Untitled</title> <script language="javascript"> function ChangePage() { if (document.search.form_boy.value != ""){location.href="boy.html"}; else if (document.search.form_girl.value != ""){location.href="girl.html"}; } </script> </head> <body> <form action="" method="post" name="search"> Boy: <input type="text" name="form_boy"><br> Girl: <input type="text" name="form_girl"><br> <input type="button" value="Submit" onClick="ChangePage()"> </form> </body> </html> |
![]() |
| Viewing: Dev Shed Forums > Web Design > HTML Programming > Form and Data |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|