/    Sign up×
Community /Pin to ProfileBookmark

Dynamic change of drop down

I have a drop down that lists:

Title
Attendee
Date

I then want another drop down or text field to appear depending on what I pick in the drop down I stated above…. How can I accomplish this?

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@FangSep 14.2007 — <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<title>change 2nd select</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<script type="text/javascript">
var varieties=[
["varieties","granny smith","golden delicious","jonathan"],
["varieties","anjou","bartlett","conference"],
["varieties","valencia","pineapple","pera"]
];

function Box2(idx) {
var f=document.myform;
f.box2.options.length=null;
for(i=0; i<varieties[idx].length; i++) {
f.box2.options[i]=new Option(varieties[idx][i], i);
} <br/>
}
window.onload=function(){Box2(0);};
&lt;/script&gt;

&lt;style type="text/css"&gt;

&lt;/style&gt;

&lt;/head&gt;
&lt;body&gt;
&lt;form name="myform" method="post" action="http://www.mysite.com/mysite"&gt;
&lt;select name="box1" onchange="Box2(this.selectedIndex)"&gt;
&lt;option value="a"&gt;apple&lt;/option&gt;
&lt;option value="b"&gt;pear&lt;/option&gt;
&lt;option value="c"&gt;orange&lt;/option&gt;
&lt;/select&gt;
&lt;select name="box2"&gt;

&lt;/select&gt;
&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;
×

Success!

Help @firman 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,
)...