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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T18:55:49+00:00 2026-05-24T18:55:49+00:00

Can I have a link that when clicked displays text inside a textarea? This

  • 0

Can I have a link that when clicked displays text inside a textarea?

This is what I have.

<script type="text/javascript">
mybutton: onclick {
document.myform2.mytextfield2.value = "Test";
}
</script>

<form name="myform2">
<input type="button" name="mybutton" value="Go">
<input type="text" name="mytextfield2">
</form>

Please tell me what I got wrong.

  • 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-24T18:55:50+00:00Added an answer on May 24, 2026 at 6:55 pm

    The problem is that mybutton: onclick { ... } is not an executable statement; it’s a fragment of code.

    There are several ways to fix your code.

    1. Declare a function in the script, and declare an onclick event handler in the button.

    <script type="text/javascript">
    function myfunc() {
    document.myform2.mytextfield2.value = "Test";
    }
    </script>
    
    <form name="myform2">
    <input type="button" name="mybutton" value="Go" onclick="myfunc()">
    <input type="text" name="mytextfield2">
    </form>
    

    OR 2. Give the button an ID, put the script block after the button, and modify the event handler registration code.

    <form name="myform2">
    <input type="button" name="mybutton" value="Go" id="mybutton">
    <input type="text" name="mytextfield2">
    </form>
    
    <script type="text/javascript">
    document.getElementById("mybutton").onclick = function() {
    document.myform2.mytextfield2.value = "Test";
    }
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this href link with text either attivo or non attivo User can
I have a subscription link on a page that the logged in users can
I have two PHP files that I need to link. How can I link
I have a database which is in Access (you can get it link text
i have this code that should create a dialog with the page google inside
I'm having a problem with getElementbyId as follows: <script type=text/javascript> <!-- function show_links(locale) {
I have this web page I'm developing that displays multiple images of one product
I have established a link using Netbeans and Paradox driver and can query the
I have a textbox where users can enter the link to a YouTube video.
how can i select the current link via jquery if I have a div

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.