/    Sign up×
Community /Pin to ProfileBookmark

text link to dropdown

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>

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@swonDec 26.2002 — You want 2 dropdown-menues, yes? One with, for example ford and toyota and by choosing, another dropdown width the models, is that right?
Copy linkTweet thisAlerts:
@sandalwoodauthorDec 26.2002 — Exactly!
Copy linkTweet thisAlerts:
@swonDec 26.2002 — 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!
Copy linkTweet thisAlerts:
@sandalwoodauthorDec 27.2002 — 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
Copy linkTweet thisAlerts:
@swonDec 27.2002 — which name should it be?
×

Success!

Help @sandalwood spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...