473,503 Members | 12,383 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

noob - jumping to next select box

Hey folks --

I have a series of selectboxes on a web form. I would like to have a
javascript jump the focus to the next selectbox when the user presses a key.
Each box has the values 1 through 6-9, depending. So normally someone who is
used to it can just hit 1 <tab> 3<tab> 5<tab>1<tab>9<tab> -- I'd like to
take the tabbing out.

So what's really nice is if the box doesn't jump when the user doesn't
select a proper value.

I've been looking at java scripts and I'm not sure how to reference the next
selectbox, or how to check that the key pressed was in the proper range. Can
someone help me out?

Here's what FireFox's WebDeveloper .8 says about my form:

Form
Id Name Method Action
questions post ./shop_report.php

Elements
Id Name Type Value
1 select
2 select
3 select
4 select
5 select
6 select
7 select
8 select
9 select
10 select
...

through about 200 or so.
Jul 23 '05 #1
6 1677
Steve Lefevre wrote:
I have a series of selectboxes on a web form. I would like to have a
javascript jump the focus to the next selectbox when the user presses a key.
Each box has the values 1 through 6-9, depending. So normally someone who is
used to it can just hit 1 <tab> 3<tab> 5<tab>1<tab>9<tab> -- I'd like to
take the tabbing out.

You are after the element tabIndex property, have a look here:

http://www.mozilla.org/docs/dom/domr...f.html#1002691

So what's really nice is if the box doesn't jump when the user doesn't
select a proper value.

How can they not select a "proper value"? Perhaps you should
look at making sure the content of the select is only valid
values, rather than pestering the user if they can't guess what
is "proper" and what isn't.
I've been looking at java scripts and I'm not sure how to reference the next
selectbox, or how to check that the key pressed was in the proper range. Can
someone help me out?


Use the tabIndex property to control navigation. There is also
an item index (look for "item" method at the above reference):

element.item(index)

but that is based on the order the elements are placed in the
DOM tree and may not be the same order as your required
tabIndex.
Jul 23 '05 #2
On Sat, 18 Sep 2004 14:50:12 +1000, Fred Oz <oz****@iinet.net.auau> wrote:

[snip]
Use the tabIndex property to control navigation. There is also
an item index (look for "item" method at the above reference):

element.item(index)

but that is based on the order the elements are placed in the
DOM tree and may not be the same order as your required
tabIndex.


That documentation is either proprietary, or wrong. Elements do not have
an item method; collections do. Even then it is preferable to use
subscripting as not all browsers may support the item and namedItem
methods.

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #3

"Fred Oz" <oz****@iinet.net.auau> wrote in message
news:41***********************@per-qv1-newsreader-01.iinet.net.au...

How can they not select a "proper value"? Perhaps you should
look at making sure the content of the select is only valid
values, rather than pestering the user if they can't guess what
is "proper" and what isn't.


What I mean is that I don't think I should use the KeyPress event, because
proper values are only 1 through 6 to 9. So one box might be 1-7, and maybe
the user hits '8', or 'g'. I don't want it jumping to the next box in that
case.

So, yes, the select box does have only proper values in it, but the keyboard
doesn't ;)

I've been looking at java scripts and I'm not sure how to reference the next selectbox, or how to check that the key pressed was in the proper range. Can someone help me out?
Use the tabIndex property to control navigation. There is also
an item index (look for "item" method at the above reference):

element.item(index)

Can I pass the index as a variable? Or can I just reference the select box
name, passed as a variable to the function?

but that is based on the order the elements are placed in the
DOM tree and may not be the same order as your required
tabIndex.

Jul 23 '05 #4
Post a brief sample that shows what you are trying to do,
otherwise we are just guessing...

Cheers, Fred
Jul 23 '05 #5

"Fred Oz" <oz****@iinet.net.auau> wrote in message
news:41***********************@per-qv1-newsreader-01.iinet.net.au...
Post a brief sample that shows what you are trying to do,
otherwise we are just guessing...

The following is the description from the grandparent thread. I don't have
any code attemps, because, like I say, I'm a noobie ;)

I have a series of selectboxes on a web form. I would like to have a
javascript jump the focus to the next selectbox when the user presses a key.
Each box has the values 1 through 6-9, depending. So normally someone who is
used to it can just hit 1 <tab> 3<tab> 5<tab>1<tab>9<tab> -- I'd like to
take the tabbing out.

So what's really nice is if the box doesn't jump when the user doesn't
select a proper value.

I've been looking at java scripts and I'm not sure how to reference the next
selectbox, or how to check that the key pressed was in the proper range. Can
someone help me out?

Here's what FireFox's WebDeveloper .8 says about my form:

Form
Id Name Method Action
questions post ./shop_report.php

Elements
Id Name Type Value
1 select
2 select
3 select
4 select
5 select
6 select
7 select
8 select
9 select
10 select
...

through about 200 or so.
Jul 23 '05 #6

"Fred Oz" <oz****@iinet.net.auau> wrote in message
news:41***********************@per-qv1-newsreader-01.iinet.net.au...
Post a brief sample that shows what you are trying to do,
otherwise we are just guessing...


Aw, heck, here's a brief, non-java psue-code attempt at what I'm after

on KeyUp(MoveToNext)

MoveToNext{
if ( selected_value is in_selectbox_values ) {
goto form.elements.next()
}
}

Dig?
Jul 23 '05 #7

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

Similar topics

3
6057
by: We need more power captain | last post by:
Hi, I know less than a noob, I've been asked to do some compiles in VC++ 6 without knowing too much at all. (I'm a COBOL program normally so this is all too much for me) I open VC++6, open...
2
11466
by: Scott Eade | last post by:
I am using select()/focus() to position the cursor at a particular field on a form. This works, but when the user presses the Tab key in IE the cursor jumps to the address bar rather than the next...
3
1737
by: jalkadir | last post by:
By jump I mean ending unexpectedly. The program below, like the jumping beens, has an unusual behaviour. When the noted lines are not present the program terminates disregarding the rest of the...
4
1563
by: Mason Barge | last post by:
I'm learning how to build a website. So far I've gotten pretty good with HTML, CSS, and Paint Shop Pro, and I'm currenly learning the basics of Javascript. I'm hoping, eventually, to build and...
4
1804
by: Pupeno | last post by:
Hello, I want to jump over a method in the class hierarchy, that is: If I have class A(object), clas B(A), class C(B) and in C, I want a method to do exactly what A does but not what B does in...
1
1955
by: Japskunk | last post by:
I am having trouble updating a SQL table through the GridView "Auto" Enable Edit Feature... I am connecting to a SQL 2000 Server with a SQLDataSource I have created the Update Query in the Command...
4
2994
by: Buzby | last post by:
I want a drop down date selection box on a form in the format of Mon 18 June 2007, that will go say 400 days in advance from the current date. Can anyone point me in the right direction as I...
2
1276
by: pinman | last post by:
hi. i'm pretty much a noob to c# and visual studio and am trying to create a simple login method. i have created a users table in the database and can add users by inputing there md5 encrypted...
1
1624
by: prathna | last post by:
Hi I have this following code <script> function displayFields() { document.getElementById('Label12').style.display = 'none'; document.getElementById('Label13').style.display =...
0
7098
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...
0
7296
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,...
0
7364
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...
1
7017
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...
0
7470
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...
1
5026
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...
0
4696
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3186
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...
0
1524
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 ...

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.