Reputation: 301
Using Jquery or javascript. What is the best way to send the value of an option from a drop down menu to the textarea listed below. So if the user selects one of the names in the drop down it will sends its value to the textarea field. the select menu is in its own iframe (iframe name is boxmain) and the text area is in its own iframe (iframe name is boxform).
<select id="usernames" name="usernames">
<option value=""></option>
<option value="name001">JeffCool</option>
<option value="name002">IAMsam</option>
</select>
<textarea name="name" cols="15" rows="1" class="class"></textarea>
Upvotes: 0
Views: 3080
Reputation: 630389
The simplest way is to use a .change()
event handler on your <select>
, the simplest form of this:
$("#usernames").change(function() {
$("textarea[name=pst]").val($(this).val());
});
What this does is what the <select>
changes value, it takes the .val()
(the value
of the <option>
just chosen) and sets that value on the <textarea>
using the same method.
Upvotes: 2