sjp060497
asked on
Making a Javascript "Keypad"?
Hello all, again,
I am trying to write a simple script that will allow me to display a small keypad of letters. When the user clicks on the letter "A", for example, the "A" will appear in a text box of the form, and will be submitted with the form when the user hits the select button. I do not want to use the "input type=button" option, but would rather like to use my own image for the letter "A" button. I found a script on the Web that is close to what I want, but uses the "input type=button" option. I tried to modify it, but I must be missing something obvious.
The script I have been playing with is as follows:
<HTML>
<HEAD>
<TITLE>Untitled</TITLE>
<script language="javascript">
var letter ='A'
function enter(obj, string)
{
obj.expr.value += string
}
</script>
</HEAD>
<BODY>
<form>
<input type="text" name="expr" size=20><p>
<a href="javascript:enter(thi s.form,let ter)">clic k here to enter A</a>
<p>
<input type="button" value="A" onClick="enter(this.form,l etter)">
</form>
</BODY>
</HTML>
In the above example, I tried to using both the "input type=button" option, and a "anchor" option (just to see how they both work). The anchor option is what I ultimately want.
The "input type=button" works fine in this example, but the "anchor" option does not work.
Any ideas what I am doing wrong?
Thanks in advance,
Stephen Pintauro
I am trying to write a simple script that will allow me to display a small keypad of letters. When the user clicks on the letter "A", for example, the "A" will appear in a text box of the form, and will be submitted with the form when the user hits the select button. I do not want to use the "input type=button" option, but would rather like to use my own image for the letter "A" button. I found a script on the Web that is close to what I want, but uses the "input type=button" option. I tried to modify it, but I must be missing something obvious.
The script I have been playing with is as follows:
<HTML>
<HEAD>
<TITLE>Untitled</TITLE>
<script language="javascript">
var letter ='A'
function enter(obj, string)
{
obj.expr.value += string
}
</script>
</HEAD>
<BODY>
<form>
<input type="text" name="expr" size=20><p>
<a href="javascript:enter(thi
<p>
<input type="button" value="A" onClick="enter(this.form,l
</form>
</BODY>
</HTML>
In the above example, I tried to using both the "input type=button" option, and a "anchor" option (just to see how they both work). The anchor option is what I ultimately want.
The "input type=button" works fine in this example, but the "anchor" option does not work.
Any ideas what I am doing wrong?
Thanks in advance,
Stephen Pintauro
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If you want images, change all the <INPUT TYPE="BUTTON" to
<A HREF="javascript:void(0);" ONCLICK....>
<IMG SRC="....."></A>
Michel
<A HREF="javascript:void(0);"
<IMG SRC="....."></A>
Michel
ASKER
Thanks Michel,
Works great!
Stephen Pintauro
Works great!
Stephen Pintauro
ASKER