HTML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsWeb DesignHTML Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old September 14th, 2000, 09:15 AM
ccm ccm is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2000
Location: Hong Kong
Posts: 73 ccm User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 h 31 m 9 sec
Reputation Power: 9
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>

Reply With Quote
  #2  
Old September 15th, 2000, 08:30 AM
bramsey bramsey is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2000
Location: USA
Posts: 226 bramsey User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 40 m 35 sec
Reputation Power: 9
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>

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignHTML Programming > Form and Data


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
Stay green...Green IT