J Wynia wrote:[color=blue]
> PC-Dad wrote:
>[color=green]
>> I'd like to make a form in which the user would input her zip code.
>> When they submit then the script would compare to the list of zips that
>> I service. If their zip is included re-direct to page A or if not
>> included re-direct to page B.
>>
>> Would anyone be able to assist me here?
>>
>> Thanks;
>>
>> Scott Solar is
>> PC-Dad.com
>>[/color]
>
> Here's a sample HTML document that switches the form's "action" to a
> different page if the "zip" field is filled in. You can modify this
> greatly to do whatever you want by changing the stuff in the condition
> part of the "if" statement. Of course, once you get more than a few
> conditions, you'll need something more complex than the if, but this
> will work for most basic cases.
>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
> <html>
> <head>
> <title> New Document </title>
> <script language="JavaScript">[/color]
language attribute is deprecated, use the type attribute instead.
[color=blue]
> <!--[/color]
Hiding scripts is an obsolete practice.
[color=blue]
> function check_zip(){
> $zip = testform.zip.value;[/color]
There is very good reason why you do not see that shortcut notation very
often in this newsgroup. IE creates a global scope to the form object
that is neamed testform, no other browser (AFAIK) do that. So the above
line would be more cross-browser as:
document.forms['testform'].elements['zip'].value;
[color=blue]
> if(($zip == null) || ($zip == ""))
> {
> testform.action = "form_processor1.php";[/color]
same here with the global-ness of testform.
[color=blue]
> } else {
> testform.action = "form_processor2.php";[/color]
ditto.
--
Randy
comp.lang.javascript FAQ -
http://jibbering.com/faq & newsgroup weekly