Tried the code and it didn't work.
Main Topics
Browse All TopicsI am using the function below to generate a drop down list. My problem is that I am trying to reuse the list 3 times on the same page, but the list will not populate after the first. Any help would be appreciated. Thanks
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<SCRIPT>
function populate()
{
var selectBox2 = document.getElementById('s
for( i = 0; selectBox2.length > 0; i++ )
{
selectBox2.options[i] = null;
if( selectBox2.length > 0 )
selectBox2.length--;
}
if( document.getElementById('s
{
selectBox2.options[0] = new Option( 'Select Program/Unit', '0' );
selectBox2.options[1] = new Option( 'Financial Services', 'Financial Services' );
if( document.getElementById('s
document.getElementById('s
}
if( document.getElementById('s
{
selectBox2.options[0] = new Option( 'Select Program/Unit', '0' );
selectBox2.options[1] = new Option( 'www', 'www' );
if( document.getElementById('s
document.getElementById('s
}
if( document.getElementById('s
{
selectBox2.options[0] = new Option( 'Select Program/Unit', '0' );
selectBox2.options[1] = new Option( 'Offices', 'Offices' );
selectBox2.options[2] = new Option( 'Operations', 'Operations' );
selectBox2.options[3] = new Option( 'Program', 'Program' );
if( document.getElementById('s
document.getElementById('s
}
if( document.getElementById('s
{
selectBox2.options[0] = new Option( 'Select Program/Unit', '0' );
selectBox2.options[1] = new Option( 'ddd', 'ddd' );
selectBox2.options[2] = new Option( 'aaa', 'aaa' );
selectBox2.options[3] = new Option( 'bbb', 'bbb' );
if( document.getElementById('s
document.getElementById('s
}
else
{
selectBox2.options[0] = new Option( 'Select Program/Unit', '0' );
selectBox2.options[1] = new Option( 'nnn', 'nnn' );
selectBox2.options[2] = new Option( 'nnn', 'nnn' );
if( document.getElementById('s
document.getElementById('s
}
}
</SCRIPT>
</head>
<body>
<table><tr>
<td><br>
<select name="div1" class="text" ID="selectBox1" onChange="populate();">
<option value="0">Select Division</option>
<option value="admin">Administrati
<option value="adult">Adult Services</option>
<option value="assist">Assistance Programs</option>
<option value="cfs">Children and Family Services</option>
<option value="fss">Family Self Sufficiency</option>
</select>
</td>
<td bgcolor="#FFFFFF"><select name="program1" ID="selectBox2">
<option value="0">Select Organization</option>
</select>
</td>
</tr></table>
</body>
</html>
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Is this what you are looking for??
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<SCRIPT>
function populate()
{
var selectBox2 = document.getElementById('s
for( i = 0; selectBox2.length > 0; i++ )
{
selectBox2.options[i] = null;
if( selectBox2.length > 0 )
selectBox2.length--;
}
if( document.getElementById('s
{
selectBox2.options[0] = new Option( 'Select Program/Unit', '0' );
selectBox2.options[1] = new Option( 'Financial Services', 'Financial Services' );
if( document.getElementById('s
document.getElementById('s
}
if( document.getElementById('s
{
selectBox2.options[0] = new Option( 'Select Program/Unit', '0' );
selectBox2.options[1] = new Option( 'www', 'www' );
if( document.getElementById('s
document.getElementById('s
}
if( document.getElementById('s
{
selectBox2.options[0] = new Option( 'Select Program/Unit', '0' );
selectBox2.options[1] = new Option( 'Offices', 'Offices' );
selectBox2.options[2] = new Option( 'Operations', 'Operations' );
selectBox2.options[3] = new Option( 'Program', 'Program' );
if( document.getElementById('s
document.getElementById('s
}
if( document.getElementById('s
{
selectBox2.options[0] = new Option( 'Select Program/Unit', '0' );
selectBox2.options[1] = new Option( 'ddd', 'ddd' );
selectBox2.options[2] = new Option( 'aaa', 'aaa' );
selectBox2.options[3] = new Option( 'bbb', 'bbb' );
selectBox3.options[0] = new Option( 'Select Program/Unit', '0' );
selectBox3.options[1] = new Option( 'nnn', 'nnn' );
selectBox3.options[2] = new Option( 'nnn', 'nnn' );
if( document.getElementById('s
document.getElementById('s
}
}
</SCRIPT>
</head>
<body>
<table><tr>
<td><br>
<select name="div1" class="text" ID="selectBox1" onChange="populate();">
<option value="0">Select Division</option>
<option value="admin">Administrati
<option value="adult">Adult Services</option>
<option value="assist">Assistance Programs</option>
<option value="cfs">Children and Family Services</option>
<option value="fss">Family Self Sufficiency</option>
</select>
</td>
<td bgcolor="#FFFFFF"><select name="program1" ID="selectBox2">
<option value="0">Select Organization</option>
</select></td><td bgcolor="#FFFFFF"><select name="program2" ID="selectBox3">
<option value="0">Select Organization</option>
</select>
</td>
</tr></table>
</body>
</html>
Here a tested and working code:
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<SCRIPT>
var aOpt = new Array();
aOpt["admin"] = [
['Select Program/Unit', '0' ],
['Financial Services', 'Financial Services']];
aOpt["adult"] = [
['Select Program/Unit', '0'],
['www', 'www']];
aOpt["assist"] = [
['Select Program/Unit', '0'],
['nnn', 'nnn'],
['nnn', 'nnn']];
aOpt["cfs"] = [
['Select Program/Unit', '0'],
['Offices', 'Offices'],
['Operations', 'Operations'],
['Program', 'Program']];
aOpt["fss"] = [
['Select Program/Unit', '0'],
['ddd', 'ddd'],
['aaa', 'aaa'],
['bbb', 'bbb']];
function populate(theSel){
var theForm = theSel.form;
theForm.selectBox3.style.d
var opt = theForm.selectBox2.options
opt.length = 0;
var newOpt = aOpt[theSel.value];
for(var i=0;i<newOpt.length;i++){
opt[i] = new Option(newOpt[i][0],newOpt
}
}
</SCRIPT>
</head>
<body>
<form>
<table><tr>
<td>
<select name="div1" class="text" ID="selectBox1" onChange="populate(this);"
<option value="0">Select Division</option>
<option value="admin">Administrati
<option value="adult">Adult Services</option>
<option value="assist">Assistance Programs</option>
<option value="cfs">Children and Family Services</option>
<option value="fss">Family Self Sufficiency</option>
</select>
</td>
<td bgcolor="#FFFFFF"><select name="program1" ID="selectBox2" name="selectBox2">
<option value="0">Select Organization</option>
</select>
</td>
<td bgcolor="#FFFFFF"><select name="program2" ID="selectBox3" name="selectBox3" style="display:none">
<option value="0">Select Organization</option>
</select>
</td>
</tr></table>
<input type=submit>
</form>
</body>
</html>
Business Accounts
Answer for Membership
by: BatalfPosted on 2005-03-08 at 16:35:49ID: 13492004
Try
electBox2' ); 0;
electBox1' ).options[ document.g etElementB yId('selec tBox1').se lectedInde x].value == "admin" )
electBox3' ).style.di splay != 'none' ) electBox3' ).style.di splay = 'none'; electBox1' ).options[ document.g etElementB yId('selec tBox1').se lectedInde x].value == "adult" )
electBox3' ).style.di splay != 'none' ) electBox3' ).style.di splay = 'none'; electBox1' ).options[ document.g etElementB yId('selec tBox1').se lectedInde x].value == "fss" ) electBox3' ).style.di splay != 'none' ) electBox3' ).style.di splay = 'none'; electBox1' ).options[ document.g etElementB yId('selec tBox1').se lectedInde x].value == "cfs" )
electBox3' ).style.di splay != 'none' ) electBox3' ).style.di splay = 'none';
electBox3' ).style.di splay != 'block' ) electBox3' ).style.di splay = 'block';
function populate()
{
var selectBox2 = document.getElementById('s
selectBox2.options.length=
if( document.getElementById('s
{
selectBox2.options[0] = new Option( 'Select Program/Unit', '0' );
selectBox2.options[1] = new Option( 'Financial Services', 'Financial Services' );
if( document.getElementById('s
document.getElementById('s
}
if( document.getElementById('s
{
selectBox2.options[0] = new Option( 'Select Program/Unit', '0' );
selectBox2.options[1] = new Option( 'www', 'www' );
if( document.getElementById('s
document.getElementById('s
}
if( document.getElementById('s
{
selectBox2.options[0] = new Option( 'Select Program/Unit', '0' );
selectBox2.options[1] = new Option( 'Offices', 'Offices' );
selectBox2.options[2] = new Option( 'Operations', 'Operations' );
selectBox2.options[3] = new Option( 'Program', 'Program' );
if( document.getElementById('s
document.getElementById('s
}
if( document.getElementById('s
{
selectBox2.options[0] = new Option( 'Select Program/Unit', '0' );
selectBox2.options[1] = new Option( 'ddd', 'ddd' );
selectBox2.options[2] = new Option( 'aaa', 'aaa' );
selectBox2.options[3] = new Option( 'bbb', 'bbb' );
if( document.getElementById('s
document.getElementById('s
}
else
{
selectBox2.options[0] = new Option( 'Select Program/Unit', '0' );
selectBox2.options[1] = new Option( 'nnn', 'nnn' );
selectBox2.options[2] = new Option( 'nnn', 'nnn' );
if( document.getElementById('s
document.getElementById('s
}
}