You are here: Re: PHP / Javascript menu list population « PHP Programming Language « IT news, forums, messages
Re: PHP / Javascript menu list population

Posted by Chung Leong on 10/04/38 11:31

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>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация