473,698 Members | 2,179 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 2535
"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
3880
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 any of its children have. Is there any way I can force an update to the parent TIMESTAMP field...
8
3483
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
1926
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 because the Required property for this field is set to True. Enter a value in this field."
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 of which I know I can use: NEW, OLD, TG_WHEN, TG_OP and TG_RELNAME. I can use these to get...
0
1336
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 HQ and so on....
3
2269
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 the client side at runtime (think MapQuest or Google Maps). We use a COTS product here to handle...
1
1632
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
3509
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 subform. The subform has another field that I want to AutoNumber or increment number BUT has to go...
3
4668
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 autonumber as I need to start a new sequence for each new Project_ID. I've tried putting a max()...
0
8674
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9157
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8895
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
8861
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7728
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6518
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4369
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3046
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
3
2001
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.