AutoAdvance between input fields

by "John Aitchison" <jaitchis(at)hwy.com.au>

 Date:  Sun, 4 Nov 2001 20:09:47 +1100
 To:  Hwg-basics(at)hwg.org
  todo: View Thread, Original

Hi all

I am trying to write a questionnaire that does NOT require the user 
to use the mouse between input fileds. Most input fields are single 
character only (say a rating between 1 and 5) and so simply 
pressing the key should be enough to enter their answer and send 
them on to the next field.

I have done enough tests to make me reasonably confident that this 
can be done with some calls to focus() in the onKeyUp event 
handler, but it seems that keystroke processsing is IE4 and NN4 and 
above only.

Does anyone have any ideas for an elegant workaround for earlier 
browsers ? I guess I could just make the users hit tab or whatever, 
but  I  keep thinking there should be a simple way to do autoadvance.

I found 
http://www.insidedhtml.com/tips/elements/ts22/page2.asp
which uses a timer for a problem which is somewhat related and if I 
work through it it might give me some ideas. I have never used a 
timer in js, so I guess I need to learn.  

One rough idea I have is to check if the field has a value. If it does, 
then move the focus to the next field. There are some obvious 
problems if the user wants to go back and make corrections.. a 
special correction mode is I guess a possibility.

Well, if anyone has been there done that or even better still has an 
elegant solution, I am all ears.

Thanks

HTML: hwg-basics mailing list archives, maintained by Webmasters @ IWA

This page is part of a preserved archive of archives.hwg.org. The site is no longer active and its content is not maintained. For enquiries about this archive, write to archive(at)iwanet.org.