/    Sign up×
Community /Pin to ProfileBookmark

dropdownbox decided content of the page

hi

i have a dropdownbox with 3 different options. there is a box below the dropdownbox with some content. i want this content to change instantly when you change the option in the dropdownbox (without the page reloading). This must be possible with javascript….

please help me
thanks

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@bathurst_guyFeb 17.2008 — Yes it is possible with JavaScript. Look up document.getElementById and innerHTML and onChange.
Copy linkTweet thisAlerts:
@spliffauthorFeb 17.2008 — thanks. anyone who wants to say more on that and make my life easier thanks ?
Copy linkTweet thisAlerts:
@LeonsbuddydaveFeb 17.2008 — This should be what you're looking for.
<i>
</i>&lt;html&gt;
&lt;head&gt;
&lt;script type="text/javascript" language="javascript"&gt;
function changeContent() {
var content = document.form1.select1.value;
document.getElementById("adiv");
adiv.innerHTML = "" + content + "";
}
&lt;/script&gt;
&lt;/head&gt;
&lt;body onload="changeContent()"&gt;
&lt;style type="text/css"&gt;
#adiv {
border: solid 2px black;
height: 400px;
width: 400px;
}
&lt;/style&gt;
&lt;form name="form1"&gt;
&lt;select name="select1" onChange="changeContent()"&gt;
&lt;option value="This content was created with the first option."&gt;Content 1&lt;/option&gt;
&lt;option value="Similarily, this content was created with option two."&gt;Content 2&lt;/option&gt;
&lt;option value="And Finally, option Threes content is displayed."&gt;Content 3&lt;/option&gt;
&lt;/select&gt;
&lt;/form&gt;
&lt;div id="adiv"&gt;
&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
Copy linkTweet thisAlerts:
@spliffauthorFeb 17.2008 — excellent, thanks
×

Success!

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