/    Sign up×
Community /Pin to ProfileBookmark

Populating a textbox from a <select> menu?

I am trying to make it so when you choose a item out of a drop down menu it prepopulates a text box with info about that selection. I cant get it to work. Any help or could point me to a tutorial?

Thanks
Adam

to post a comment
JavaScript

9 Comments(s)

Copy linkTweet thisAlerts:
@oleragFeb 10.2004 — [code=php]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Content-Script-Type" content="text/javascript">
<title>Sample</title>
<script type="text/javascript">
<!--
function execute(selObj) {
document.forms[0].field1.value = selObj.options[selObj.selectedIndex].value;
}
// -->
</script>

<div style="text-align: center;">
<strong>Sample</strong>
</div>

<form action="">
<p>
<select name="selectList1" size="5" onChange="execute(this)">
<option value="1">Option 1</option>
<option value="2">Option 2</option>
<option value="3">Option 3</option>
<option value="4">Option 4</option>
<option value="5">Option 5</option>
</select>
<br>
<input type="text" name="field1" disabled>
</p>
</form>

[/code]
Copy linkTweet thisAlerts:
@ShampieFeb 10.2004 — Hello,

this should not be to hard, and possible without javascript for useage with any browser

try the following:

<select name="list" id="select" onChange="output.value=this.value">

<option value="a very yummie apple">apple</option>

<option value="skies can be blue" >skies</option>

</select>

<input type="text" name="output">

g'luck!
Copy linkTweet thisAlerts:
@adamthenewbieauthorFeb 10.2004 — Thanks. Is there a way i can make it so the user cant edit the text box?
Copy linkTweet thisAlerts:
@oleragFeb 10.2004 — Already been provided...

<input type="text" name="field1" disabled>
Copy linkTweet thisAlerts:
@adamthenewbieauthorFeb 10.2004 — thanks again!!.. Sorry to bug you all again.. but can you make it so the disabled text is black instead of gray?
Copy linkTweet thisAlerts:
@adamthenewbieauthorFeb 10.2004 — actually can I make it a link??
Copy linkTweet thisAlerts:
@fredmvFeb 10.2004 — [i]Originally posted by adamthenewbie [/i]

[B]actually can I make it a link?? [/B][/QUOTE]
What do you want to be made a link?
Copy linkTweet thisAlerts:
@adamthenewbieauthorFeb 10.2004 — the text box that was prepopulated
Copy linkTweet thisAlerts:
@oleragFeb 11.2004 — Well, if the values in the selection listing are actually web

page URLs you could either...

1) Take the user to that page when a selection is made, or...

2) Change the selection listing to a list of URLs.
×

Success!

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