Need help with a dynamic dropdown list.

Discussion in 'JavaScript' started by Andie, Jan 9, 2006.

  1. #1
    Hello Guys;

    Please note that I am new to javascript.

    I am writing a form in asp and would like to use javascript to create a dynamic dropdown list to enable users to select a competition from the first dropdown and then I want the second dropdown to create a list of races for that competition chosen.

    I have error checking in the form when it is submitted, so if errors are found in the form is reloaded with the users data, so I need the options that were selected to be loaded also.

    Can anyone help?

    Andie
     
    Andie, Jan 9, 2006 IP
  2. dave487

    dave487 Peon

    Messages:
    701
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    0
    #2
    not sure about asp but in php you could use
    <select name="color">
    <option <?php if($color=="green"){ echo"selected"} ?>>green</option>
    <option <?php if($color=="red"){ echo"selected"} ?>>red</option>
    <option <?php if($color=="blue"){ echo"selected"} ?>>blue</option>
    </select>
    PHP:
    I am sure asp is similar....

    You would then need to run a javascript using onload to look at the value selected in the first list and populate the second list accordingly.
     
    dave487, Jan 9, 2006 IP