views:

305

answers:

3

I have a small project, wherein I need to develop a keypad with all the digits+backspace+decimal (all as buttons). These digits when clicked should populate a form field (say a text box). This keypad should be located next to the form field as a link.

The keypad should be preferably Javascript/AJAX. Also the keypad routine should have a close button in order to minimize the popup keypad. (It's very much similar to a calendar control which we see in ticketing websites.)

To round up the keypad routine does nothing fancy but to just populate the form field, when the digits (buttons) are clicked.

I need help with coding the keyboard routine. How do I design the javascript? How to include the buttons (for the digits+decimal+backspace in the file)? How to code the part where when the buttons are clicked, then that value is showed in the form field?

Any help is greatly appreciated.

Thanks

A: 

Jan I needed help with coding the keyboard routine.i mean how do i design the javascript file.how to include the buttons(for the digits+decimal+backspace in the file).how to code the part where when the buttons are clicked,then that value is showed in the form field

swathi
editing your question to incorporate this (should be a comment or question edit rather than an answer) :)
warren
+1  A: 

Where's the problem?

No need to use ajax. Very quick and dirty example:

test here --> http://www.codebase.es/so/numpad.html

<html>
<head><title></title></head>
<body>

<script> function $(id) { return document.getElementById(id); } </script>

<input id="num" type="text" readonly="true"/>
<input type="button" value="..." onclick="$('keypad').style.display='inline-block';"/>

<div id="keypad" style="display:none; background:#AAA; vertical-align:top;">
<input type="button" value="7" onclick="$('num').value+=7;"/>
<input type="button" value="8" onclick="$('num').value+=8;"/>
<input type="button" value="9" onclick="$('num').value+=9;"/><br/>
<input type="button" value="4" onclick="$('num').value+=4;"/>
<input type="button" value="5" onclick="$('num').value+=5;"/>
<input type="button" value="6" onclick="$('num').value+=6;"/><br/>
<input type="button" value="1" onclick="$('num').value+=1;"/>
<input type="button" value="2" onclick="$('num').value+=2;"/>
<input type="button" value="3" onclick="$('num').value+=3;"/><br/>
<input type="button" value="X" onclick="$('keypad').style.display='none'"/>
<input type="button" value="0" onclick="$('num').value+=0;"/>
<input type="button" value="&larr;" onclick="$('num').value=$('num').value.substr(0,$('num').value.length-1);"/>
</div>

</body>
</html>

Do not use "as is"... use css stylesheets, functions, etc.

Pedro Ladaria
+1 - You helped with code that would cause problems if turned in as is, but I liked your style.
James Black
A: 

This is great. I would love to do this inline to create dropdowns for text boxes. Say, a text box, width 35, 4 text options below... Can you help?

Web 8080