Hi Greg Griffiths,
Thanks for the link. Also I have changed your
example to the code below and was wondering If
I used that It would still work in non-IE browsers.
Code:
<html>
<head>
<title></title>
<script language="javascript" type="text/javascript">
// function takes a display NAME and the VALUE for the new element and then adds it to the dropdown specified in the other parameter
function addOption(whichDD,name,value)
{
// create a reference to the SELECT and the form
var theDD=eval(whichDD);
// create the new OPTION
var newOption;
newOption= new Option (name,value);
// position
var insertAt = theDD.options.length;
// create the space
theDD.options.length=theDD.options.length + 1;
// add the option
theDD.options[insertAt] = newOption;
}
function populateDD()
{
// get the value
var firstDD=document.myForm.first_dropdown.value;
// reset the dropdown
document.myForm.second_dropdown.length=0;
// Populate the second DD
switch (firstDD)
{
case '1':
addOption('document.myForm.second_dropdown','33');
addOption('document.myForm.second_dropdown','145');
addOption('document.myForm.second_dropdown','146');
addOption('document.myForm.second_dropdown','147');
addOption('document.myForm.second_dropdown','155');
addOption('document.myForm.second_dropdown','156');
addOption('document.myForm.second_dropdown','164');
addOption('document.myForm.second_dropdown','166');
addOption('document.myForm.second_dropdown','GTV');
addOption('document.myForm.second_dropdown','SPIDER');
addOption('document.myForm.second_dropdown','75');
break;
case '2':
addOption('document.myForm.second_dropdown','ROCSTA');
break;
case '3':
addOption('document.myForm.second_dropdown','DB7');
addOption('document.myForm.second_dropdown','V8');
break;
}
}
</script>
</head>
<body>
<form name="myForm">
<table align="center">
<tr>
<td>
<SELECT NAME="first_dropdown" ONCHANGE="populateDD();">
<option value="0" SELECTED>Any Make</option>
<option value="1">ALFA ROMEO</option>
<option value="2">ASIA</option>
<option value="3">ASTON MARTIN</option>
</select>
<select name="second_dropdown">
</select>
</form>
</body>
</html>