Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
Password Reminder
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 10th, 2007, 02:10 PM
Friend of Wrox
Join Date: Mar 2004
Location: Ottawa, , Canada.
Posts: 139
Thanks: 0
Thanked 0 Times in 0 Posts
Default change content of textarea from select


I have these sample strings
test1 = "This is sample string 1.";
test2 = "Sample string 2, present!";

And this:
<select name="blurbselect" onChange="setBlurb(this);">
  <option value="0"></option>
  <option value="1">Test1</option>
  <option value="2">Test2</option>

Now what I would like to do is that when I select Test1 from the select box, it will put the value of the string in a text area. Now I know that I could put the string value straight in the select, but my strings will be much longer, and I don't want to deal with it that way... Can someone suggest another option?

Reply With Quote
  #2 (permalink)  
Old April 26th, 2007, 06:03 AM
Authorized User
Join Date: Oct 2006
Location: Yerevan, , Armenia.
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts

If I understand you right, this code will work for you.


test0 = "";
test1 = "test string 1";
test2 = "test string 2";
function setBlurb() {
var otionValue = document.form.blurbselect.value;
if (otionValue == "0") {
  document.form.textarea.value = test0;
} else if (otionValue == "1")
  document.form.textarea.value = test1;
  else if (otionValue == "2")
  document.form.textarea.value = test2;
<form name = 'form'>
<select name="blurbselect" onChange = "setBlurb();">
  <option value="0" ></option>
  <option value="1" >Test1</option>
  <option value="2" >Test2</option>
  <textarea name = "textarea" value = ""></textarea>


Guess switch operator will work faster than if-else-if for long list of options.

Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to insert textarea content into MySQL? a5xo3z1 Beginning PHP 14 October 2nd, 2008 01:47 PM
select either textarea or radiobutton pavani ASP.NET 2.0 Basics 1 March 21st, 2008 04:35 AM
Displaying textarea content to html table keithc Pro PHP 2 December 1st, 2006 03:12 AM
Display data in textarea with select statement Alex_forever MySQL 6 April 27th, 2004 06:05 PM
change TextArea in GUI from another class jermsv1 Java GUI 0 October 28th, 2003 02:50 AM

All times are GMT -4. The time now is 01:30 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.