Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


How to write  option chosen in "select" to "textarea" element

Posted on 2006-04-23
Medium Priority
Last Modified: 2012-06-21

I have a form with a select element. When the user makes a selection, I need to write the selection to a textarea element. Every time the user makes a new selection in the select, I need to write it on a new line in the textarea. How would I do this. I am new to Javascript.

Thank you
Question by:tr5

Accepted Solution

nabsol earned 2000 total points
ID: 16519953

Hope this is what you want.

<script language="JavaScript">
 function writetotextarea(sbox, tarea)
    if(sbox.value != -1){
     tarea.value += sbox.options[sbox.selectedIndex].text + "\n"

<select id="myselect" onchange="writetotextarea(this, mytextarea)">
<option value=-1>select Option</option>
<option value=1>Option1</option>
<option value=2>Option2</option>
<option value=3>Option3</option>
<option value=4>Option4</option>
<option value=5>Option5</option>
<option value=6>Option6</option>

<textarea id="mytextarea" rows="6"></textarea>


Author Comment

ID: 16520020
Yes it is. Thank you.

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

581 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question