/    Sign up×
Community /Pin to ProfileBookmark

Making a textbox appear

Im trying to make a text box appear whenever I make a specific selection from a select list. I have several choices in the select list, but when someone chooses “Other” I need a textbox to appear so they can fill it in. Any help would be appreciated.

Thanks
JRoC

to post a comment
JavaScript

1 Comments(s)

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

<script type="text/javascript">
onload=function() {
document.getElementsByName('textarea1')[0].style.display='none';
document.getElementsByName('select1')[0].onchange=decision;
}

function decision() {
var oSelect=document.form1.select1;
document.getElementsByName('textarea1')[0].style.display=(oSelect.options[oSelect.selectedIndex].value=='other')? 'block' : 'none';
}
</script>

</head>
<body>
<form action="#" name="form1">
<fieldset><legend>decisions</legend>
<select name="select1">
<option value="this">this</option>
<option value="that">that</option>
<option value="other">other</option>
</select>
<textarea name="textarea1">other stuff</textarea>
</fieldset>
</form>
</body>
</html>
×

Success!

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