473,543 Members | 2,061 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Incrementing a field

I've got an embedded system that uses a javascript-enabled browser as a
front end.

The input system consists of an encoder which generates + and - chars, and
a couple of keys that generate Tab and Shift-Tab for navigation.

Each field in the form is numerical, and has certain properties; for
example, one field represents %, and has a min of 0, a max of 100, and
increments of 1.

I need to come up with some javascript code that would take take those +
and - chars, and increment/decrement the field values so that the user can
'dial in' the value they need....

I am a complete newbie in the world of Javascript, and I can't figure out
where to begin....

(I've got some other stuff already written, but this aspect of the page is
stumping me....)

I would appreciate any suggestions or references for this....

--Yan
Jan 17 '06 #1
6 2526
"Captain Dondo" <ya*@NsOeSiPnAe Mr.com> wrote in message
news:pa******** *************** *****@NsOeSiPnA eMr.com...
I've got an embedded system that uses a javascript-enabled browser as a
front end.

The input system consists of an encoder which generates + and - chars, and
a couple of keys that generate Tab and Shift-Tab for navigation.

Each field in the form is numerical, and has certain properties; for
example, one field represents %, and has a min of 0, a max of 100, and
increments of 1.

I need to come up with some javascript code that would take take those +
and - chars, and increment/decrement the field values so that the user can
'dial in' the value they need....

I am a complete newbie in the world of Javascript, and I can't figure out
where to begin....

(I've got some other stuff already written, but this aspect of the page is
stumping me....)

I would appreciate any suggestions or references for this....

--Yan


If the following doesn't help (watch for word-wrap),
could you post a stripped down version of your code?

<html>
<head>
<title>plusminu s.htm</title>
<script type="text/javascript">
function plusminus(num,b oo) {
var val = document.getEle mentById("num"+ num).value;
(boo) ? val++ : val--;
document.getEle mentById("num"+ num).value = val;
}
</script>
</head>
<body>
<form action="" method="get">
<input type="text" id="num1" size="3" maxlength="3" value="0">
<input type="button" value="+" onclick="plusmi nus(1,true)">
<input type="button" value="-" onclick="plusmi nus(1,false)">
<br>
<input type="text" id="num2" size="3" maxlength="3" value="0">
<input type="button" value="+" onclick="plusmi nus(2,true)">
<input type="button" value="-" onclick="plusmi nus(2,false)">
</form>
</body>
</html>
Jan 17 '06 #2
On Tue, 17 Jan 2006 08:33:00 -0600, McKirahan wrote:

<html>
<head>
<title>plusminu s.htm</title>
<script type="text/javascript">
function plusminus(num,b oo) {
var val = document.getEle mentById("num"+ num).value;
(boo) ? val++ : val--;
document.getEle mentById("num"+ num).value = val;
}
</script>
</head>
<body>
<form action="" method="get">
<input type="text" id="num1" size="3" maxlength="3" value="0">
<input type="button" value="+" onclick="plusmi nus(1,true)">
<input type="button" value="-" onclick="plusmi nus(1,false)">
<br>
<input type="text" id="num2" size="3" maxlength="3" value="0">
<input type="button" value="+" onclick="plusmi nus(2,true)">
<input type="button" value="-" onclick="plusmi nus(2,false)">
</form>
</body>
</html>


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
Jan 17 '06 #3
"Captain Dondo" <ya*@NsOeSiPnAe Mr.com> wrote in message
news:pa******** *************** ****@NsOeSiPnAe Mr.com...
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_min us.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.getEle mentById("Num"+ num).value;
if (key == 43) val++;
if (key == 45) val--;
document.getEle mentById("Num"+ num).value = val;
document.getEle mentById("Num"+ num).select();
// cancel the default submit
if (e.preventDefau lt) {
e.preventDefaul t();
} else {
window.event.re turnValue = false;
}
}
function window.onload() {
document.getEle mentById("Num1" ).focus();
document.getEle mentById("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="ret urn plus_minus(1)">
<input type="text" id="Num2" size="3" maxlength="3" value="0"
style="text-align:center" onkeypress="ret urn plus_minus(2)">
<input type="text" id="Num3" size="3" maxlength="3" value="0"
style="text-align:center" onkeypress="ret urn plus_minus(3)">
</form>
</body>
</html>

The only keys that will work are:
Tab, Shift+Tab, Plus, and Minus.
Jan 17 '06 #4
McKirahan wrote:
Try this. Watch for word-wrap.
<snip>
The only keys that will work are:
Tab, Shift+Tab, Plus, and Minus.


Thanks. I'm trying to get it to work; I'll post back w/ code once I'm
done.... (It's a learning thing for me....)

--Yan
Jan 17 '06 #5
JRS: In article <pa************ *************** @NsOeSiPnAeMr.c om>, dated
Tue, 17 Jan 2006 07:08:32 remote, seen in news:comp.lang. javascript,
Captain Dondo <ya*@NsOeSiPnAe Mr.com> posted :

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....


In a well-designed application, it should be possible to do anything
without a mouse (except pointing at locations of pictures).

Consider those using a laptop in a train speeding over bumpy track !

--
© John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 MIME. ©
Web <URL:http://www.merlyn.demo n.co.uk/> - FAQish topics, acronyms, & links.
Proper <= 4-line sig. separator as above, a line exactly "-- " (SonOfRFC1036)
Do not Mail News to me. Before a reply, quote with ">" or "> " (SonOfRFC1036)
Jan 18 '06 #6
On Wed, 18 Jan 2006 13:57:10 +0000, Dr John Stockton wrote:

In a well-designed application, it should be possible to do anything
without a mouse (except pointing at locations of pictures).

Consider those using a laptop in a train speeding over bumpy track !


Well, I have 12 function keys, up-down-left-right keys, a
pick/select/enter (whatever you want to call it) key, and a + and a - key.
The 12 function keys are 'bookmarks' or 'shortcuts'; they take you
directly to a web page.

With that, I have to do browser navigation and fill a form with numerical
data.

An interesting problem, especially for someone who doesn't speak
javascript very well...
Jan 19 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
3870
by: Robin Tucker | last post by:
Hi, I'm in the process of implementing a multi-user system containing an adjacency list (tree structure). I'm using a TIMESTAMP field on each record in the adjacency list in order to tell when a node has been changed since the last read. Sometimes though, it is useful to flag a "parent" (or all ancestors or a node) as being changed if...
8
3472
by: JD via AccessMonster.com | last post by:
I am trying to create a field where the primary key field will produce JDP- 001; where the three letters come from the first name, middle intial and last name of my table. I want to auto increment only if the three letters are reproduced. e.g. JDP-001 JDP-002 YPT-001 YRT-001 RPT-001
1
1912
by: K. Davis | last post by:
I need to increment the maximum value of a field of a table by 1 when a form opens a blank record. (e.g. =max(!![trip_number}) so the logic and references are working at the form level. I've tried a number of variants tied to the before update event, but always get the message "The field 'tripmain.trip_number' can't contain a Null value...
2
1800
by: Tim Vadnais | last post by:
Hi, My boss wants to add some logging functionality to some of our tables on update/delete/insert. I need to log who, when, table_name, field name, original value and new value for each record, but only logging modified fields, and he wants me to do this wing postgres pgSQL triggers. We are given 10 automatically created variables. Some...
0
1331
by: icezcube | last post by:
I am not a programmer and a newbie with MS Access. I hope you guys can help me with my problem. I'm creating an IT hardware inventory database for my company. We have a few branches and each branches will have their own branch code. For example :- PKGL07 PKGL14 KLIA ...
3
2251
by: Adam Sandler | last post by:
Hello, I'm able to reproduce my problem but I haven't been able to figure out why it is happening. MS does have an article about such behavior in http://support.microsoft.com/default.aspx?scid=kb;en-us;Q320731 but the workaround prescribed in the KB isn't particularly helpful. The project I'm working on serves up a custom jpg image on...
1
1622
by: senger.kim | last post by:
Hello World, I'm relatively new to MS Access (2003) and am trying to implement something that I feel should be simple but cannot find a solution. Hoping that you can help me or point me where to seek more help. Let's start with a hypothetical database: ID Name 1 Peter
1
3499
by: asandiego | last post by:
Hey guys, this is my first post here but have been checking this site a lot for anything I need. I hope someone can lead me to what I should do or just an idea to what can be done. What I'm trying to do: I have a Form that has a subform. My primary form has a field that autonumber and this field has a one to many relationship to a field in my...
3
4657
by: bkberg05 | last post by:
Hi - I have a field called Sequence on a continuous subform. The Sequence field belongs to a table called Project_Draw. This table has many 'Draw' records for each 'Project' record. So then the subform is tied to the main form by Project_ID. I want the Sequence field to automatically increment each time I add a new record. I can't use the...
0
7355
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7594
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7746
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7356
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7697
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5285
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3394
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1830
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
979
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.