Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-09-2012, 09:28 PM   PM User | #1
pbracing33b
New Coder

 
Join Date: Mar 2012
Posts: 70
Thanks: 6
Thanked 0 Times in 0 Posts
pbracing33b is an unknown quantity at this point
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.
pbracing33b is offline   Reply With Quote
Old 03-09-2012, 10:03 PM   PM User | #2
jmrker
Senior Coder

 
jmrker's Avatar
 
Join Date: Aug 2006
Location: FL
Posts: 2,764
Thanks: 29
Thanked 453 Times in 447 Posts
jmrker will become famous soon enough
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. -->
jmrker is offline   Reply With Quote
Users who have thanked jmrker for this post:
pbracing33b (03-10-2012)
Old 03-09-2012, 10:36 PM   PM User | #3
pbracing33b
New Coder

 
Join Date: Mar 2012
Posts: 70
Thanks: 6
Thanked 0 Times in 0 Posts
pbracing33b is an unknown quantity at this point
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.
pbracing33b is offline   Reply With Quote
Old 03-09-2012, 11:48 PM   PM User | #4
jmrker
Senior Coder

 
jmrker's Avatar
 
Join Date: Aug 2006
Location: FL
Posts: 2,764
Thanks: 29
Thanked 453 Times in 447 Posts
jmrker will become famous soon enough
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">
jmrker is offline   Reply With Quote
Users who have thanked jmrker for this post:
pbracing33b (03-10-2012)
Old 03-10-2012, 01:51 AM   PM User | #5
pbracing33b
New Coder

 
Join Date: Mar 2012
Posts: 70
Thanks: 6
Thanked 0 Times in 0 Posts
pbracing33b is an unknown quantity at this point
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.
pbracing33b is offline   Reply With Quote
Old 03-10-2012, 02:29 AM   PM User | #6
jmrker
Senior Coder

 
jmrker's Avatar
 
Join Date: Aug 2006
Location: FL
Posts: 2,764
Thanks: 29
Thanked 453 Times in 447 Posts
jmrker will become famous soon enough
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.
jmrker is offline   Reply With Quote
Reply

Bookmarks

Tags
dom, html, javascript, numpad

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:19 PM.


Advertisement
Log in to turn off these ads.