Click to See Complete Forum and Search --> : text link to dropdown
sandalwood
12-26-2002, 03:31 PM
I found this great code that does exactly what I need it to do, only it fills a dropdown menu with results based on a text link, and I would like to use a nother dropdown. Can someone help me with this, please?
Here is the script for the form:
<form name="dynmenu_form">
<a href="javascript:void(null);" onClick="FillList(0);return false">Ford</a><br />
<a href="javascript:void(null);" onClick="FillList(1);return false">Toyota</a><br /><br />
<select name="models" style="width: 160px" onChange="if (this.selectedIndex != 0) {alert(this.options[selectedIndex].value);}">
<option></option>
</select>
</form>
You want 2 dropdown-menues, yes? One with, for example ford and toyota and by choosing, another dropdown width the models, is that right?
sandalwood
12-26-2002, 03:53 PM
Exactly!
So, try out that!
<body>
<form name="dynmenu_form">
<select name="marks" style="width: 160px" onChange="if (this.selectedIndex != 0) {makedropdown(this.value)}">
<option value=0>bitte wählen
<option value=ford>Ford
<option value=toyota>Toyota
</select>
<div id="drop2"></div>
<script language=javascript>
function makedropdown(val)
{
ford_models = new Array("fordmodell1","fordmodell2","fordmodell3");
toyota_models = new Array("toyotamodell1","toyotamodell2","toyotamodell3");
obj = document.getElementById("drop2");
elm = "<select name=models style=\"width: 160px\">";
switch(val)
{
case "ford":
for(i=0;i<ford_models.length;i++)
{
elm += '<option value="'+ford_models[i]+'">'+ford_models[i];
}
break;
case "toyota":
for(i=0;i<toyota_models.length;i++)
{
elm += '<option value="'+toyota_models[i]+'">'+toyota_models[i];
}
break;
}
elm += "</select>";
obj.innerHTML = elm;
}
</script>
</form>
</body>
does not works in IE4 and NS4!
sandalwood
12-27-2002, 08:29 AM
Swon,
That is pretty close to what I need, but I am returning the values to a database, so I need to be able to assign the name of the second dropdown to coincide with the database column. That's why it is easier to have the second dropdown on the page at all time