...

View Full Version : skipping focus of input fields



Choopernickel
06-05-2003, 06:57 PM
Gents, Ladies, Others,

I'm trying to assign (in a function which executes on page load) a tabindex of -1 to all input fields with a certain value in their className property.
( inputField.className.toLowerCase().indexOf("invis")>-1 )

However, the assignment of tabindex = -1 (either as straight property assignment or using setAttribute() ) doesn't have the same effect as putting <input ... tabindex="-1"> in the HTML - which I'm trying to avoid, since I've already got the class definition containing "invis" for my stylesheet, and it's an attribute that all skip-desired fields share.

Is there a way to calculate the current tab index, or the current index of the element in the form's inputs collection?

Hmmm. I may have just answered my own question. I'll keep this thread updated as I flesh it out a bit more.

brothercake
06-05-2003, 07:43 PM
Note that you can't set more than one element to the same tabindex - or rather, you probably can but shouldn't because tabindex is supposed to be a sequence. What are you trying to gain by doing this - do you want to affect the way a user navigates through a form dynamically? If so, you might consider starting with the miniumum and generating each element in the DOM - if you leave a big space between tabindex numbers - like in jumps of 100 - it will leave you space to generate fields in between others.

Just a thought.

Choopernickel
06-05-2003, 08:59 PM
These are inputs I'm using to display calculated values; as such, I'm removing all input-type appearances from them via CSS (hence the "invis" class), and I don't want them ever to be tabbed into. I guess I could use td.innerText, but is that going to be as easy to manipulate? Yeah, probably so. Maybe I'll go that route.

Thanks for the tip on the unique tabindexing. I found by accident once that an element with tabindex="-1" will never be focused on via the tab key. I figure it's a better way to skip the focus than onfocus="this.blur()", as it doesn't interrupt the actual tabbing through of a document, which I love to do.

ETA: Ending up with the td.innerText route, because while I got it working by assigning a nextFocus calculator function, it didn't really enhance the activity on the form.

CUT BAIT, I SAY! CUT BAIT!

ca_redwards
06-06-2003, 12:56 AM
I did something similar for a calendar component that I created. Basically, I wanted an ineditable textfield next to a button that would ultimately populate the textfield via JavaScript. In my popup calendar example (http://www.angelfire.com/ca/redwards/html__.calendar.html), I do exactly that. Using an input that is marked readonly, I change its value via JavaScript.

This works nicely.

:ca_redwards.


Originally posted by Choopernickel
These are inputs I'm using to display calculated values; as such, I'm removing all input-type appearances from them via CSS (hence the "invis" class), and I don't want them ever to be tabbed into. I guess I could use td.innerText, but is that going to be as easy to manipulate? Yeah, probably so. Maybe I'll go that route.

Thanks for the tip on the unique tabindexing. I found by accident once that an element with tabindex="-1" will never be focused on via the tab key. I figure it's a better way to skip the focus than onfocus="this.blur()", as it doesn't interrupt the actual tabbing through of a document, which I love to do.

ETA: Ending up with the td.innerText route, because while I got it working by assigning a nextFocus calculator function, it didn't really enhance the activity on the form.

CUT BAIT, I SAY! CUT BAIT!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum