Re: PHP / Javascript menu list population




bigfella wrote:
> Hello Folks,
>
> I would like a web page to have 2 menu lists
>
> The contents of the second menu list depending on the selection made in
> the first.

The easiest way to do this is to create all the secondary menus and
show/hide them depending on the selection of the primary menu.

Example:

<script language="Javascript">

var cur_val = '0';

function ShowSecond(sel) {
var new_val = '0';
if(sel.selectedIndex != -1) {
new_val = sel.options[sel.selectedIndex].value;
}
document.getElementById('sel_' + cur_val).style.display = 'none';
document.getElementById('sel_' + new_val).style.display = 'inline';
cur_val = new_val;
}

</script>
<select onchange="ShowSecond(this)">
<option value="0" selected>- Select -</option>
<option value="1">One</option>
<option value="2">Two</option>
<option value="3">Three</option>
<option value="4">Four</option>
</select>
<select id="sel_1" style="display: none">
<option>List One</option>
</select><select id="sel_2" style="display: none">
<option>List Two</option>
</select><select id="sel_3" style="display: none">
<option>List Three</option>
</select><select id="sel_4" style="display: none">
<option>List Four</option>
</select><select id="sel_0" disabled>
<option>Placeholder</option>
</select>

.



Relevant Pages

  • Re: PHP / Javascript menu list population
    ... >> The contents of the second menu list depending on the selection made in ... do a menu using lists and css. ...
    (comp.lang.php)
  • Re: multiple pick from drop-down list
    ... Each sheet will have anywhere from a couple pay items up to ... selection model is the accidental over-writing of existing data. ... We have setup drop-down lists through data ...
    (microsoft.public.excel)
  • Re: Asp.net Dropdownlist selected index in changed
    ... back it will lose selection from fifth to first item in the list. ... The selected index of first two lists remain same but only thirds are ... private void BindSectionDropDownlist() ... Code for Searching according to the selection of third dropdown ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: multiple pick from drop-down list
    ... Let all your friends at NJDOT know that you are still working ... selection model is the accidental over-writing of existing data. ... We have setup drop-down lists through ...
    (microsoft.public.excel)
  • Re: Asp.net Dropdownlist selected index in changed
    ... The selected index of first two lists remain same but only thirds are ... private void BindSectionDropDownlist() ... Code for Searching according to the selection of third dropdown ...
    (microsoft.public.dotnet.framework.aspnet)