Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Apr 2003
    Location
    Atlanta, GA
    Posts
    487
    Thanks
    0
    Thanked 0 Times in 0 Posts

    skipping focus of input fields

    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.

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.
    Last edited by brothercake; 06-05-2003 at 08:47 PM.
    "Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark

  • #3
    Regular Coder
    Join Date
    Apr 2003
    Location
    Atlanta, GA
    Posts
    487
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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!
    Last edited by Choopernickel; 06-05-2003 at 10:26 PM.

  • #4
    Regular Coder
    Join Date
    Dec 2002
    Posts
    169
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Make it readonly.

    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, 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!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •