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 932971
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T20:45:23+00:00 2026-05-15T20:45:23+00:00

how to change the text of a textarea when a dropdown list is selected.

  • 0

how to change the text of a textarea when a dropdown list is selected. Here is my code…

<html>
<head>
<script type="text/javascript">
function fifa()
{
abc=document.forms[0].browsers.value;
if(abc=="");
document.form1.text1value="you selected A";
else if
document.form1.text1.value="you selected B";
else
document.form1.text1.value="you selected C";
}
</script>
</head>

<body>

<form name="form1">
Choose which browser you prefer:
<select id="browsers" onchange="fifa()">
<option value="A">A</option>
<option value="B">B</option>
<option value="C">C</option>
</select>

<textarea name="text1">

</textarea>
</form>

</body>
</html>

-thannx in advance

-Miss Subanki

  • 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-05-15T20:45:24+00:00Added an answer on May 15, 2026 at 8:45 pm

    Here is a corrected version of your function:

    function fifa()
    {
        var frm = document.forms[0];
        var abc = frm.browsers.value;
        if (abc === "A")
            frm.text1.value = "You selected A";
        else if (abc === "B")
            frm.text1.value = "You selected B";
        else
            frm.text1.value = "You selected C";
    }
    

    Points of interest. First, use the var keyword to declare variables inside of your functions. This ensures that your local variables will remain visible only inside the function in which they are needed. For large JavaScript programs, this is indispensible. Otherwise, without the var keyword, your variables will have global scope, possibly overwriting earlier global variables.

    Second, you must learn and understand JavaScript syntax. Examine my code and yours.

    Third, I am using the === operator to test for equality instead of the == operator. Both will give the same result in this piece of code, but the === operator does not enforce type coercion in JavaScript. Trust me that later down the line, this will come in useful. Study up on this issue if you are not familiar with it.

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

Sidebar

Related Questions

Well i first wrote a Javascrip function that would change the text in a
How do I change label's text on textarea's onkeyup? I've tried this but does
I'm tracking how fast does the text of a textArea change. If it changes
I am generating user control according to search result. And allowing to change text
I have a bunch of textarea's on a page with copy and paste codes
I have an area where a chunk of HTML (shown below) is added dynamically
I am working on ASP.NET 3.5 website project and using jQuery to warn users
I currently have a page that allows a user to enter different types of
In .NET (at least in the 2008 version, and maybe in 2005 as well),

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.