Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7907365
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T11:23:41+00:00 2026-06-03T11:23:41+00:00

How can I add the variable value to my text area based on the

  • 0

How can I add the “variable value” to my text area based on the users selection in the drop-down box above.

Here is the code that II have so far:

<html>
<head>

<body>

<select id="dropdown">
    <option value="">None</option>
    <option value="textArray1">text1</option>
    <option value="textArray2">text2</option>
    <option value="textArray3">text3</option>
    <option value="textArray4">text4</option>
</select>

<br /><br />

<textarea id="mytext"></textarea>

<script type="text/javascript">

var textArray1 = 'this is going to be a long sting of text for text 1 value';
var textArray2 = 'this is going to be a long sting of text for text 2 value';
var textArray3 = 'this is going to be a long sting of text for text 3 value';
var textArray4 = 'this is going to be a long sting of text for text 4 value';

var mytextbox = document.getElementById('mytext');
var mydropdown = document.getElementById('dropdown');

mydropdown.onchange = function(){
      mytextbox.value = mytextbox.value  + this.value; //to appened
     //mytextbox.innerHTML = this.value;
}
</script>

</body>
</html>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T11:23:43+00:00Added an answer on June 3, 2026 at 11:23 am

    Try making this change in your onchange function:

    mytextbox.value = mytextbox.value  + window[this.value]; //to appened
    

    You could’ve also used eval() on the this.value, but eval() is about as popular as a red-headed step child. See this question for more info on the differences.

    jsFiddle example

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I add the check-box variable value to my text area based on
How can i assign value to javasctipt variable from code-behind (C#)? <script type=text/javascript> String.prototype.trim
alt text http://img153.imageshack.us/img153/9417/snapshotapp.jpg How can i fetch the value 500 to a variable from
Lets say i wanted to add another variable to the database can anybody tell
Where Linux/Unix environment variables are kept? How can I add my own environment variable
i am trying to add method or variable declarations to org.eclipse.jdt.core.dom.CompilationUnit, but I can't
Users on my site can add nodes of a custom type (let's call it
How can I get the return value of only the Name Variable? RunspaceConfiguration rsConfig
I have the following code: $(#tag-add-button).click(function () { var text = $(#tagadd).val(); var tagcounter=0;
how can I add custom control on the basis of sessionScope variable. I try

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.