I would like to automatically populate a drop down menu when the page
loads based on the selection of an item in a different drop down menu.
I made a test page that when drop down #1 changes, drop down #2
populates. Does anyone know how to get drop down #2 to populate based
on what is selected in drop down #1 when the page loads?
Here is my test code:
*************** *************** *************** *************** ************
<html>
<head>
<script language="javas cript">
var phaseArray = new Array(4);
var phaseTypeId = new Array(4);
var phaseId = new Array(4);
phaseArray[0] = "Define";
phaseId[0] = "phs_2003000000 01";
phaseTypeId[0] = "pht_2003000000 01";
phaseArray[1] = "Measure";
phaseId[1] = "phs_2003000000 02";
phaseTypeId[1] = "pht_2003000000 01";
phaseArray[2] = "Analyze";
phaseId[2] = "phs_2003000000 03";
phaseTypeId[2] = "pht_2003000000 01";
phaseArray[3] = "Project Start-Up";
phaseId[3] = "phs_2003000000 06";
phaseTypeId[3] = "pht_2003000000 02";
function populateMenu(s) {
var i=0,j=1;
document.overvi ew.phase.option s.length = 1; //delete current
options
document.overvi ew.phase.option s[0].selected = true;
for (var i=0; i<phaseArray.le ngth; i++){
if(s == phaseTypeId[i]) {
document.overvi ew.phase.option s.length = j;
document.overvi ew.phase.option s[j] = new Option(phaseArr ay[i]);
document.overvi ew.phase.option s[j].value = phaseId[i];
if("phs_2003000 00006" == phaseId[i])
document.overvi ew.phase.option s[j].selected = true;
j++;
}
}
}
</script>
</head>
<body>
<form name="overview" id="overview" action="test2.j sp"
method="post">
<select name="phaseType "
onChange="popul ateMenu(documen t.overview.phas eType.options[document.overvi ew.phaseType.op tions.selectedI ndex].value);">
<option value="pht_2003 00000001">Phase 1</option>
<option selected value="pht_2003 00000002">Phase 2</option>
</select><br />
<select name="phase" id="phase" style="width:10 0px;">
<option></option>
</select>
</form>
<script>populat eMenu("phs_2003 00000006");</script>
</body>
</html>
*************** *************** *************** *************
Thanks
loads based on the selection of an item in a different drop down menu.
I made a test page that when drop down #1 changes, drop down #2
populates. Does anyone know how to get drop down #2 to populate based
on what is selected in drop down #1 when the page loads?
Here is my test code:
*************** *************** *************** *************** ************
<html>
<head>
<script language="javas cript">
var phaseArray = new Array(4);
var phaseTypeId = new Array(4);
var phaseId = new Array(4);
phaseArray[0] = "Define";
phaseId[0] = "phs_2003000000 01";
phaseTypeId[0] = "pht_2003000000 01";
phaseArray[1] = "Measure";
phaseId[1] = "phs_2003000000 02";
phaseTypeId[1] = "pht_2003000000 01";
phaseArray[2] = "Analyze";
phaseId[2] = "phs_2003000000 03";
phaseTypeId[2] = "pht_2003000000 01";
phaseArray[3] = "Project Start-Up";
phaseId[3] = "phs_2003000000 06";
phaseTypeId[3] = "pht_2003000000 02";
function populateMenu(s) {
var i=0,j=1;
document.overvi ew.phase.option s.length = 1; //delete current
options
document.overvi ew.phase.option s[0].selected = true;
for (var i=0; i<phaseArray.le ngth; i++){
if(s == phaseTypeId[i]) {
document.overvi ew.phase.option s.length = j;
document.overvi ew.phase.option s[j] = new Option(phaseArr ay[i]);
document.overvi ew.phase.option s[j].value = phaseId[i];
if("phs_2003000 00006" == phaseId[i])
document.overvi ew.phase.option s[j].selected = true;
j++;
}
}
}
</script>
</head>
<body>
<form name="overview" id="overview" action="test2.j sp"
method="post">
<select name="phaseType "
onChange="popul ateMenu(documen t.overview.phas eType.options[document.overvi ew.phaseType.op tions.selectedI ndex].value);">
<option value="pht_2003 00000001">Phase 1</option>
<option selected value="pht_2003 00000002">Phase 2</option>
</select><br />
<select name="phase" id="phase" style="width:10 0px;">
<option></option>
</select>
</form>
<script>populat eMenu("phs_2003 00000006");</script>
</body>
</html>
*************** *************** *************** *************
Thanks
Comment