How to make a dropdown box that adds text to a message box?

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
lucas20042004
Forum Newbie
Posts: 7
Joined: Mon May 15, 2006 7:39 am

How to make a dropdown box that adds text to a message box?

Post by lucas20042004 »

Hi, How would I make a dropdown list then select text from it and that would automatically be copied into a message box. See pic below:


Image
User avatar
Oren
DevNet Resident
Posts: 1640
Joined: Fri Apr 07, 2006 5:13 am
Location: Israel

Post by Oren »

You can't do that with PHP. Try javascript.
lucas20042004
Forum Newbie
Posts: 7
Joined: Mon May 15, 2006 7:39 am

Post by lucas20042004 »

Anyone know how to do it with javascript then?
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post by Christopher »

Something like:

Code: Select all

<script>
function setTextArea(obj) {
    document.myform.mytextarea.value = obj.value;
}
</script>
And for the form:

Code: Select all

<textarea id="mytextarea" ></textarea>
<form id="myform" >
<select onSelect="setTextArea(this)" >
...
</select>
(#10850)
Post Reply