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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:49:58+00:00 2026-05-27T06:49:58+00:00

I am trying to create a javascript function within my html document that essentially

  • 0

I am trying to create a javascript function within my html document that essentially takes the value of each <td> and places it in the textbox. Any help is very appreciated.

 <html>
    <head>
        <script type="text/javascript">
            function typeThis(){
                   document.getElementById('box_1').value = document.getElementById('typewriter');   
            }
        </script>

        <style type="text/css">
        td{
          border:1px solid black;  
          padding:10px 10px 10px 10px;
          font-family:"Helvetica Neue";
          font-size:20px; 
          }
         table{
         margin-top:50px;   
         }
        </style>
    </head>
    <body>
    <table id = "typewriter">
        <td value="k" onclick="typeThis();">k</td>    
        <td value="c" onclick="typeThis();">c</td>    
        <td value="y" onclick="typeThis();">y</td>    
        <td value="s" onclick="typeThis();">s</td>    
        <td value="p" onclick="typeThis();">p</td>    

    <input type="text" id="box_1">
    </table>
    </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-05-27T06:49:59+00:00Added an answer on May 27, 2026 at 6:49 am

    value is a custom property for a td,

    so you can access it using this method

    function typeThis(){
         document.getElementById('box_1').value = this.getAttribute("value");   
    }
    

    Side Note:
    this is how your table should look like

    <table id = "typewriter">
       <tr>
            <td value="k" onclick="typeThis();">k</td>    
            <td value="c" onclick="typeThis();">c</td>    
            <td value="y" onclick="typeThis();">y</td>    
            <td value="s" onclick="typeThis();">s</td>    
            <td value="p" onclick="typeThis();">p</td>    
       </tr>
    </table>
    
    <input type="text" id="box_1">
    

    Example 2:

    function typeThis(letter){
         document.getElementById('box_1').value = letter;   
    }
    
    <table id = "typewriter">
       <tr>
            <td value="k" onclick="typeThis('k');">k</td>    
            <td value="c" onclick="typeThis('c');">c</td>    
            <td value="y" onclick="typeThis('y');">y</td>    
            <td value="s" onclick="typeThis('s');">s</td>    
            <td value="p" onclick="typeThis('p');">p</td>    
       </tr>
    </table>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im trying to create a javascript function that sets the value of one input,
I am trying to create a checkbox dynamically using following HTML/JavaScript. Any ideas why
I am trying to create a Javascript function that will return all javascript files
I'm trying to create ONE javascript function that can do the following: onclick, a
Here is my problem, I need to create a javascript function that takes 2
I'm trying to create a javascript function that can take a fraction input string
I'm trying to create a small Javascript framework that I can use in my
Im trying to find out a good JavaScript library that can create a nice
I'm trying to create some javascript code that will display a javascript form (from
I am trying to create a JavaScript object that will deal with all of

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.