views:

83

answers:

1

How can I write numeric numbers into an input field by pressing a button?

Suppose I have a button

<input type="button" value="1">

Then I want, that when numeric pad button 1 is pressed it ads numeric words just like Windows Calculator.

A: 

I'm not sure what you are asking, but this code will add numbers to an input box (using jQuery).

HTML

<input id="data" type="text" />
<br />
<br />
<input type="button" value="1" />
<input type="button" value="2" />
<input type="button" value="3" /><br />
<input type="button" value="4" />
<input type="button" value="5" />
<input type="button" value="6" /><br />
<input type="button" value="7" />
<input type="button" value="8" />
<input type="button" value="9" />

Script

$(document).ready(function(){
 $(':button').click(function(){
  $('#data').val( $('#data').val() + $(this).val() );
 })
})
fudgey