Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Nov 2006
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    value of a button to a text box help?

    can someone help with some code for me please. i need to find out when i click a button it displays what it says on the button in a text box above it.
    the code i have so far is


    Code:
    <html>
    <head>
    
    <script type="javascript">
    
    
    
    
    
    </script>
    
    </head>
    
    <body>
    
    <form name="display">
    
    <input type="text" name="box" value ="">
    
    <tr>
    <td><input type="button" name="one" value="1"></td>
    <td><input type="button" name="two" value="2"></td>
    <td><input type="button" name="three" value="3"></td>
    </tr>
    
    </body>
    </html>

    now i know i'll need an onclick event but not sure how i get the info to display in the box

    cheers for any help guys.

  • #2
    Regular Coder
    Join Date
    Oct 2003
    Location
    on a ship
    Posts
    574
    Thanks
    1
    Thanked 6 Times in 5 Posts
    Code:
    <html>
    <head>
    
    <script type="text/javascript" for=buttoN event=onclick>
    var val=this.value;
    document.getElementById('text1').value=val;
    </script>
    
    </head>
    
    <body>
    
    <form name="display">
    
    <input type="text" name="box" value ="" id=text1>
    
    <tr>
    <td><input type="button" name="one" value="1" id=buttoN></td>
    <td><input type="button" name="two" value="2" id=buttoN></td>
    <td><input type="button" name="three" value="3" id=buttoN></td>
    </tr>
    
    </body>
    </html>
    Last edited by brandonH; 11-07-2006 at 10:40 PM. Reason: correction
    I make no attempt at pretending like I'm a professional. I offer help with what knowledge I do have.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •