Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

Q1500 How can I pass the values of selected options of a multiple select list to a textarea?

irt.org | Knowledge Base | JavaScript | Form | Q1500 [ previous next ]

Q1500 How can I pass the values of selected options of a multiple select list to a textarea?

Try:

<form>
<select
onChange="if (this.selectedIndex >-1) {
   var t='';
   for (var i=this.selectedIndex;i<this.options.length;i++) {
      if (this.options[i].selected) t += this.options[i].value + '\n';
   }
   this.form.myTextarea.value = t;
}" multiple>
<option value="one">one
<option value="two">two
<option value="three">three
<option value="four">four
</select>

<textarea name="myTextarea" cols="10" rows="10"></textarea>
</form>

Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 30th March 2008. Maintained by: Martin Webb and Michel Plungjan
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2008 irt.org, All Rights Reserved.