JavaScript Question
by Ben Ocean <beno(at)cnw.com>
|
Date: |
Mon, 17 Apr 2000 00:32:45 -0700 |
To: |
hwg-techniques(at)mail.hwg.org |
|
todo: View
Thread,
Original
|
|
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> <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