I am doing an onscreen keyboard form (don't ask), and as such I was trying to create a generic "letter" button.
The idea is to create the buttons with the letter as the id, the onclick event would (in the simplest sense) loop through the form object and find the button with the last focus. The ID would then be inserted into a textarea. For the life of me I cannot seem to find a focus property, I can find the onFocus method, but that's not what I'm after :-)
My simple code is below
keyboard.html
keyboard.jsCode:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head> <title>Javascript Keyboard</title> <script type="text/javascript" src="javascript/keyboard.js"></script> </head> <body> <form name="keyPresses" action=""> <textarea name="textBoxThing" cols="80" rows="2" ></textarea> <input type="button" value="a" name="a" onclick="keyPressed(this.form.textBoxThing)" /> <input type="button" value="b" name="b" onclick="keyPressed(this.form.textBoxThing)" /> <input type="button" value="del" name="del" onclick="keyPressed(this.form.textBoxThing)" /> <input type="button" value="cls" name="cls" onclick="keyPressed(this.form.textBoxThing)" /> </form> </body> </html>
I started Javascript today.Code:function keyPressed(inputBoxObj) { for (var i = 0; i < document.keyPresses.length; i++) { if (document.keyPresses[i].blur) { alert(document.keyPresses[i].type); } } return false; }
Thanks in advance.






Bookmarks