/    Sign up×
Community /Pin to ProfileBookmark

select tag actions

I have a select tag that when either of the last two options are selected, another div appears. As I research the internet, supposedly the “onchange” handler is supposed to work, but the only one that has is the “onclick” handler, which only worked in Firefox. Here’s the code:

[CODE]<select name=”referral” id=”referral”>
<option onchange=”document.getElementById(‘other_field’).style.display=’none’;”>Please select…</option>
<option value=”Ad” onchange=”document.getElementById(‘other_field’).style.display=’none’;”>Ad</option>
<option value=”Phone Book” onchange=”document.getElementById(‘other_field’).style.display=’none’;”>Phone Book</option>
<option value=”Friend or Relative” onchange=”document.getElementById(‘other_field’).style.display=’block’;”>Friend or Relative</option>
<option value=”Other” onchange=”document.getElementById(‘other_field’).style.display=’block’;”>Other</option>
</select>

<div style=”display:block;margin-left:50px;” id=”other_field” name=”other_field”>Please specify: <input name=”other” type=”text” id=”other” /></div>[/CODE]

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@FangJun 07.2010 — Event handlers in [I]option [/I]do not work in IE. Use an onchange in the [I]select[/I].
Copy linkTweet thisAlerts:
@tomorrows_hereauthorJun 07.2010 — Thanks Fang, I don't why I didn't think of using the select tag instead. Thank you thank you thank you!!
×

Success!

Help @tomorrows_here 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 5.18,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

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

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...