Advertisement
C_Volume2 Controls/ Forms/ Graphics/ Menus #80855

Dynamic pulldown menu

When you choose an item from the first menu, it appears related items in the seconds.

AI

AI 요약: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

소스 코드
original-source
<HTML>
<HEAD>
<TITLE></TITLE>
<script language = "JavaScript">
<!--
var names = new Array("Mark","Sarah","Carl","James");
var fruit = new Array("Banana","Strawberry","Apple");
var colors = new Array("Red", "White", "Green", "Brown");
function swapOptions(the_array_name)
{
    var numbers_select = window.document.myform.examples;
    var the_array = eval(the_array_name);
    setOptionText(window.document.myform.examples,the_array);
}
function setOptionText(the_select, the_array)
{
		the_select.length=the_array.length;
    for (c=0; c < the_array.length; c++)
    {
        the_select.options[c].text = the_array[c];
    }
}
//-->
</script>
</HEAD>
<form name="myform">
<select size="1" name="category" onChange="swapOptions(window.document.myform.category.options[selectedIndex].text);">
<option>names
<option>fruit
<option>colors
</select>
<select size="1" name="examples">
<option>-------
</select>
</form>
</body>
</html>
원본 댓글 (3)
Wayback Machine에서 복구됨