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
    Sep 2002
    Posts
    70
    Thanks
    0
    Thanked 0 Times in 0 Posts

    display numbers in the textfield when i click on the buttons?

    hi all, i am a beginner at jscript, how do i display numbers in the textfield when i click on the buttons, can someone pls help me check what's wrong with my script? thx. my code is shown below:


    <html>
    <head>
    <script type="text/javascript">
    function num1()
    {
    x=document.myForm
    at=x.field.value

    }

    </script>
    </head>
    <body>
    <form name="myForm" action="sms.htm">
    <input type="text" name="field"><br>
    <input type="button" name="one" value="1" onclick="num1()">
    <input type="button" name="two" value="2">
    <input type="button" name="three" value="3"><br>
    <input type="button" name="four" value="4">
    <input type="button" name="five" value="5">
    <input type="button" name="six" value="6"><br>
    <input type="button" name="seven" value="7">
    <input type="button" name="eight" value="8">
    <input type="button" name="nine" value="9"><br>
    <input type="button" name="star" value="*">
    <input type="button" name="zero" value="0">
    <input type="button" name="hex" value="#">
    </form>
    </body>


    </html>

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Location
    Montreal, Canada
    Posts
    644
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
    <script language="JavaScript1.2" type="text/javascript">
    function num1(what) {
      what.form.field.value += what.value;
    }
    </script>
    
    
    <input type="button" name="one" value="1" onclick="num1(this)">


  •  

    Posting Permissions

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