...

View Full Version : Best way and easiest for a beginner to set up a numpad!!!!



pbracing33b
03-09-2012, 10:28 PM
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.

<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.

jmrker
03-09-2012, 11:03 PM
Perhaps:


<input type="text" id="TextBox" value = ''><br>

<input type="image" src="Button1.gif" alt="Calculator Button #1"
onclick="document.getElementById('TextBox').value += '1'" />
<!-- etc. -->

pbracing33b
03-09-2012, 11:36 PM
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.

jmrker
03-10-2012, 12:48 AM
Show some more of your code.
I suspect you are using a <form...> tag.
If I'm correct, modify it to something like this...


<form name="myForm" action="" method="post" onsubmit="return false">

pbracing33b
03-10-2012, 02:51 AM
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.:thumbsup:

jmrker
03-10-2012, 03:29 AM
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.:thumbsup:

You're most welcome.
Happy to help.
Good Luck!
:)


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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum