Click to See Complete Forum and Search --> : chosing between two URL's


padawangeek
08-04-2003, 06:14 PM
I was asked to find a way to make a choice between 2 URL's.
I need help with figuring out how to receive the zip code in a text box then and a submit button. After normal validation I was asked to:
if (zipCode>=90000) && (zipCode<=93600)
go to URL1
else
go to URL2

This seemed so EASY or so I told my boss, but I have been spending too much time trying to get it. I have resorted to asking for help online.

I have been working as a web developer for about 3 months now and I know that there are ways to find everything you need on the web, and that will come with more experience I hope! I am wondering if this is unethical to ask for help, I have not had a lot of time to look around this forum to see the type of posts so if this is wrong of me I apologize.


Thanks for the help

pyro
08-04-2003, 06:20 PM
Try it like this:

<script type="text/javascript">
function verify(frm) {
zipcode = frm.zipcode.value;
if (zipcode >= 90000 && zipcode <= 93600) {
window.location.href = "http://www.webdevfaqs.com";
}
else {
window.location.href = "http://www.w3c.org";
}
}
</script>
</head>
<body>
<form name="myform">
<input type="text" name="zipcode">
<input type="button" value="Submit" onclick="verify(this.form);">
</form>

padawangeek
08-04-2003, 06:25 PM
thanks,
I guess I forgot the href because i tryed: window.location="http://www.blahblahblah

So I guess it was good to ask, you responded very quickly. Thanks

pyro
08-04-2003, 06:36 PM
Actually, that would work fine. Your problem was with the if command. You had:

if (zipCode>=90000) && (zipCode<=93600)

but you needed:

if (zipCode>=90000 && zipCode<=93600)

padawangeek
08-04-2003, 07:00 PM
Again, thanks Pyro! This is an ongoing learning process and sometimes I guess you forget the little things. I didn't even notice that:o

pyro
08-04-2003, 09:39 PM
No problem... :)