Re: JavaScript Question

by "Rossi Designs" <webmaster(at)rossidesigns.net>

 Date:  Mon, 17 Apr 2000 08:38:18 -0400
 To:  <hwg-techniques(at)mail.hwg.org>,
"Ben Ocean" <beno(at)cnw.com>
 References:  brightmail
  todo: View Thread, Original
The easiest way might be to use the default: clause in your case statement
to do whatever you need to do if they don't select an option.

Rossi Designs
PO Box 1084
Holly Hill, FL 32125-1084
Phone : (904) 226-8979
URL : http://rossidesigns.net
----- Original Message -----
From: Ben Ocean <beno(at)cnw.com>
To: <hwg-techniques(at)mail.hwg.org>
Sent: Monday, April 17, 2000 3:32 AM
Subject: JavaScript Question


| Hi, all;
|
| In a script I am writing for my car dealer, I have an HTML document with a
| pulldown menu for *make*. There is a default value (""). Following this,
| there is another pulldown menu for *model*. Since this is used vehicles,
| there are lots of models! I would like to utilize JavaScript to limit what
| is available for selection in the 2nd pulldown menu according to what has
| been selected in the first. However, I *don't* want some ugly JS dialogue
| box popping up in the user's face.
|
| Cracking my JS books, I've come across the concept of using switch logic.
| So, I'm thinking something like this:
|
| <!-- begin HTML code -->
|
| If you would like, you may select the make of vehicle you're interested in
| (however you don't have to).<br>
| Make:
| <select name="$make1">
| <option value="">--none--</option>
| <option value="ACUR">Acura</option>
| <option value="ALFA">Alfa Romeo</option>
| <option value="AMGE">AM General</option>
| <option value="AMMO">American Motors</option>
| <option value="ASTO">Aston Martin</option>
| etc....
|
| </select><br>&nbsp;<br>
| If you would like, you may select the model vehicle you're interested in
| (however you don't have to).<br>
| Model:
| <select name="$carline1">
|
| <!-- note: I need to get the selection box visible on screen, hence this
| location before the JS -->
|
| <script language="JavaScript" type="text/javascript">
|
| <!--
| switch ( $make1 )
|
| case ""
| document.write('<option value="ACUR,2.2CL" >Acura 2.2CL</option>')
| document.write('<option value="ACUR,2.3CL" >Acura 2.3CL</option>')
| document.write('<option value="ACUR,2.5TL" >Acura 2.5TL</option>')
| etc. with *all* models of all makes....
| break
|
| case"ACUR"
| document.write('<option value="ACUR,2.2CL" >Acura 2.2CL</option>')
| document.write('<option value="ACUR,2.3CL" >Acura 2.3CL</option>')
| document.write('<option value="ACUR,2.5TL" >Acura 2.5TL</option>')
| etc. with *just* Acura models...
| break
| etc.
| -->
|
| Is this legal? TIA,
| BenO
|
|

HWG hwg-techniques mailing list archives, maintained by Webmasters @ IWA