/    Sign up×
Community /Pin to ProfileBookmark

select + text input form field at the same time?

I’m not sure if this is possible by default, but is there a way to create with HTML a field which is presented like a select input field, but allows the user to enter a text if none of the options is applicable?

to post a comment
HTML

4 Comments(s)

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

<script type="text/javascript">
window.onload=function() {
var other = document.getElementById('other');
other.style.display = 'none';
document.form1.select1.onchange = function() {
other.style.display =(this.value=='other')? '' : 'none';
};
};
</script>

<style type="text/css">
* {margin:0;padding:0;}
</style>

</head>
<body>
<form action="#" method="post" name="form1">
<div>
<select name="select1">
<option value="foo">foo</option>
<option value="bar">bar</option>
<option value="other">other</option>
</select>
<label id="other">other<input type="text" name="other"></label>
</div>
</form>
</body>
</html>
Copy linkTweet thisAlerts:
@JazztronikauthorMay 24.2010 — Thanks a lot for your help mate! I will do it that way. Nevertheless I think I've seen it sometimes, unless it was Flash-made, this kind of select field which also permitted to enter text if none of the options was the right one.

Cheers! ?
Copy linkTweet thisAlerts:
@criterion9May 25.2010 — Thanks a lot for your help mate! I will do it that way. Nevertheless I think I've seen it sometimes, unless it was Flash-made, this kind of select field which also permitted to enter text if none of the options was the right one.

Cheers! ?[/QUOTE]


Probably using Javascript as well: http://www.baytree-cs.com/combo-select-box.html
Copy linkTweet thisAlerts:
@JazztronikauthorMay 25.2010 — Yesss!! Thank you very much Criterion9! That's exactly what I was asking about. I was quite sure I saw that in html forms. Wow! That's a lot of javascript code to implement an apparently simple field. It's too bad something like this is not implemented by HTML itself.

Best regards!
×

Success!

Help @Jazztronik 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.3,
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: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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

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