Can anyone help me how to assign option from SELECT box
by onChange event when I click on any item in the select box and want it to appear on the TEXTAREA at the and of the existing text.
For example:
when I type:
Dear Mr.
and click on the SELECT box to pick some option like in this case FirstNameLastName and I get this option value in the TEXTAREA like this: Dear Mr. FirstNameLastName
Here is my start code:
by onChange event when I click on any item in the select box and want it to appear on the TEXTAREA at the and of the existing text.
For example:
when I type:
Dear Mr.
and click on the SELECT box to pick some option like in this case FirstNameLastName and I get this option value in the TEXTAREA like this: Dear Mr. FirstNameLastName
Here is my start code:
Code:
<script language="javascript">
function swapOptions(the_name)
{
var numbers_select = window.document.the_form.txtComment.value;
var theName = eval(the_name);
setOptionText(window.document.the_form.txtComment.value, theName);
}
function setOptionText(the_select, theName)
{
the_select.options.text.value = theName;
}
</script>
<FORM name="the_form">
<select name="choose_category" onChange="swapOptions(window.document.the_form.choose_category.options[selectedIndex].text.value);">
<option selected>dogs
<option>fish
<option>birds
</select>
<TEXTAREA name="txtComment" rows=2 cols=60 size="100">