taborrg
asked on
Populate an html textarea from a drop down list
Hi,
I have an html drop down list, and need to have a textarea populated with the choice from the drop down list.
Thanks for any help.
I have an html drop down list, and need to have a textarea populated with the choice from the drop down list.
Thanks for any help.
Take a look at this jsfiddle
.
.
$("#source").change(function() {
$("#target").val( $("option:selected", this).text() );
});
ASKER
Joshua1909 - Looks promising, I will try this.
Proculopsis - I don't understand this. Where and how would it be used?
Thanks!
Proculopsis - I don't understand this. Where and how would it be used?
Thanks!
ASKER
Joshua1909,
I copied and pasted all the code, and it doesn't put anything into the textarea.
I copied and pasted all the code, and it doesn't put anything into the textarea.
ASKER
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hey Josh,
Your code works fine. My problem may have had to do with how I placed the javascript - the code that's working is in a function.
Your answer got me to the solution.
Thanks.
The code:
function addOption(x) {
sOption=document.getElemen tById('tex tBox1').va lue;
sOptions=sOption.split("\n ");
if (sOption == '') {document.getElementById(' textBox1') .value=x+" \n";}
else {
if (sOptions.length > 1) {document.getElementById(' textBox1') .value=sOp tion+x+"\n ";}
else {document.getElementById(' textBox1') .value=sOp tion+"\n"+ x+"\n";}
}
document.getElementById('t extBox1'). focus();
}
Source:
http://www.tek-tips.com/viewthread.cfm?qid=1071319
Your code works fine. My problem may have had to do with how I placed the javascript - the code that's working is in a function.
Your answer got me to the solution.
Thanks.
The code:
function addOption(x) {
sOption=document.getElemen
sOptions=sOption.split("\n
if (sOption == '') {document.getElementById('
else {
if (sOptions.length > 1) {document.getElementById('
else {document.getElementById('
}
document.getElementById('t
}
Source:
http://www.tek-tips.com/viewthread.cfm?qid=1071319
This will work, but I can't take credit for the code:
HTML
Open in new window
Javascript
Open in new window
Links:
http://jsfiddle.net/kjy112/kchRh/
http://stackoverflow.com/questions/5263839/how-to-fill-in-a-text-field-with-drop-down-selection
Cheers,
Josh