You have two choices... DOM manipulation, or DIV replacement.  The former
can get a little complex, the later is pretty straight-forward:

<select onChange="doit(this);">
  <option="color">color</option>
  <option="size">size</option>
</select>
<div id="nextSelect"></div>
<script>
  function doit(obj) {
    s = "";
    type = obj.value;
    s += "<select name=\"mySelect\">";
    if (type == "color") {
      s += "  <option value=\"blue\">blue</option>";
      s += "  <option value=\"green\">green</option>";
      s += "  <option value=\"red\">red</option>";
    }
    if (type == "size") {
      s += "  <option value=\"small\">small</option>";
      s += "  <option value=\"medium\">medium</option>";
      s += "  <option value=\"large\">small</large>";
    }
    s += "</select>";
    document.getElementById("nextSelect").innerHTML = s;
  }
</script>


-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com
AIM: fzammetti
Yahoo: fzammetti
MSN: [EMAIL PROTECTED]

On Tue, December 20, 2005 3:33 pm, Daniel Kies said:
> Do you have any examples of using javascript to populate B after A or
> something like that?
>
> On 12/20/05, Neil Erdwien <[EMAIL PROTECTED]> wrote:
>>
>> If the amount of data needed for drop down B isn't large, I'd load it
>> into Javascript objects when the original page is displayed.  Then use
>> client-side Javascript to populate B after A is chosen.
>>
>> If the amount of data is too big, I'd investigate doing the same concept
>> using client-side Javascript, but query the server for B's data using
>> AJAX methods.
>>
>>
>> Daniel Kies wrote:
>> > Greetings.  I have an app that needs to have multiple drop down boxes
>> that
>> > are related to each other.  Instead of calling an action everytime the
>> first
>> > menu is selected and querying for the data in the second drop down, I
>> want
>> > to have the values in the second drop down reflect the choice of the
>> first
>> > drop down.
>> >
>> > So Drop Down A has:
>> > 1. Color
>> > 2. Size
>> >
>> > If Color is selected, drop down B has:
>> > 1. Blue
>> > 2. Red
>> > 3. Green
>> >
>> > If Size is selected, drop down B has:
>> > 1. Small
>> > 2. Medium
>> > 3. Large
>> >
>> > I figure I can do this by calling an action when the A is selected,
>> but
>> how
>> > can I do this without calling an action after A is chosen?
>> >
>> > Thanks in advance.
>> >
>>
>> --
>> Neil Erdwien, [EMAIL PROTECTED], Web Technologies Manager
>> Computing and Network Services, Kansas State University
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to