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 6 of 6
  1. #1
    New Coder
    Join Date
    Mar 2012
    Posts
    70
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Post Best way and easiest for a beginner to set up a numpad!!!!

    Hello,

    I was wondering what the easiest and best way for a beginner like myself to set up a keypad with numbers only and have them incorporate it to a text area or box, basically the user will click the button and the number that is pressed will show up in the textarea or text box. I am wondering what the best way to do this is.
    Code:
    <input type="image" id="1" src="Button1.gif" alt="Calculator Button #1"/>
    This is the line of code (an example of it) that I am working with. So my question is what is the best way to do this.

    Thanks for the help.

  • #2
    Senior Coder jmrker's Avatar
    Join Date
    Aug 2006
    Location
    FL
    Posts
    3,146
    Thanks
    39
    Thanked 505 Times in 499 Posts
    Perhaps:
    Code:
    <input type="text" id="TextBox" value = ''><br>
    
    <input type="image" src="Button1.gif" alt="Calculator Button #1"
      onclick="document.getElementById('TextBox').value += '1'" />
    <!-- etc. -->

  • Users who have thanked jmrker for this post:

    pbracing33b (03-10-2012)

  • #3
    New Coder
    Join Date
    Mar 2012
    Posts
    70
    Thanks
    6
    Thanked 0 Times in 0 Posts
    jmrker,

    Hey this works, but now the problem is that is just shows up briefly and then disappears at the same time when the button is clicked.When I do this for #2 button it does the same thing. I made it way harder than it needed to be when I tried to do it myself.

  • #4
    Senior Coder jmrker's Avatar
    Join Date
    Aug 2006
    Location
    FL
    Posts
    3,146
    Thanks
    39
    Thanked 505 Times in 499 Posts

    Arrow

    Show some more of your code.
    I suspect you are using a <form...> tag.
    If I'm correct, modify it to something like this...
    Code:
    <form name="myForm" action="" method="post" onsubmit="return false">

  • Users who have thanked jmrker for this post:

    pbracing33b (03-10-2012)

  • #5
    New Coder
    Join Date
    Mar 2012
    Posts
    70
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Thumbs up

    Thank you very much that was exactly it. B4 this I tried adding event listeners to this and that is so much harder to do than what you've shown me here. So I am very grateful.

  • #6
    Senior Coder jmrker's Avatar
    Join Date
    Aug 2006
    Location
    FL
    Posts
    3,146
    Thanks
    39
    Thanked 505 Times in 499 Posts

    Thumbs up

    Quote Originally Posted by pbracing33b View Post
    Thank you very much that was exactly it. B4 this I tried adding event listeners to this and that is so much harder to do than what you've shown me here. So I am very grateful.
    You're most welcome.
    Happy to help.
    Good Luck!



    Note: If you submit your event listener attempt we might be able to fix it.


  •  

    Tags for this Thread

    Posting Permissions

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