"Captain Dondo" <ya*@NsOeSiPnAeMr.com> wrote in message
news:pa***************************@NsOeSiPnAeMr.co m...
On Tue, 17 Jan 2006 08:33:00 -0600, McKirahan wrote:
[snip]
I think your code uses buttons to increment and decrement.... That won't
work; I don't have a mouse. All I have is a tab key, a shift-tab key, and
a + and - key....
So what I'm trying to do is figure out some way to tab to field 'num1',
then when a '+' is entered into it, either erase it and or convert it
somehow into an increment....
I've even thought about some sort of hidden text field that would be
active and serve as input for the +- chars, and then a display only field
for the numerical value...
I can post code later today but it ain't much.... I haven't even figured
out an approach for this...
--Yan
Try this. Watch for word-wrap.
<html>
<head>
<title>plus_minus.htm</title>
<script type="text/javascript">
function plus_minus(num,e) {
// if not Netscape, get IE event
if ( !e ) e = window.event;
if ( !e ) return true;
// Get valid ascii character code
var key = typeof e.keyCode != 'undefined' ? e.keyCode : e.charCode;
// process only the "+" and "-" keys
var val = document.getElementById("Num"+num).value;
if (key == 43) val++;
if (key == 45) val--;
document.getElementById("Num"+num).value = val;
document.getElementById("Num"+num).select();
// cancel the default submit
if (e.preventDefault) {
e.preventDefault();
} else {
window.event.returnValue = false;
}
}
function window.onload() {
document.getElementById("Num1").focus();
document.getElementById("Num1").select();
alert("Press the '+' or '-' key in a field...");
}
</script>
</head>
<body>
<form>
<input type="text" id="Num1" size="3" maxlength="3" value="0"
style="text-align:center" onkeypress="return plus_minus(1)">
<input type="text" id="Num2" size="3" maxlength="3" value="0"
style="text-align:center" onkeypress="return plus_minus(2)">
<input type="text" id="Num3" size="3" maxlength="3" value="0"
style="text-align:center" onkeypress="return plus_minus(3)">
</form>
</body>
</html>
The only keys that will work are:
Tab, Shift+Tab, Plus, and Minus.