Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Tab index feature added to

by cbrandtbuffalo (Deacon)
on Sep 07, 2005 at 19:16 UTC ( #489976=perlquestion: print w/replies, xml ) Need Help??

cbrandtbuffalo has asked for the wisdom of the Perl Monks concerning the following question:

Esteemed Monks,

We recently upgraded many of our Perl modules, including We then noticed that the tab order in our forms had gone completely crazy. Focus jumped all over the place.

I did a little research, and sitting there in the list of changes for for version 3.06 is the innocent looking:

   12. Support for tab indexes.

It appears that now puts tabindex numbers in for all form elements it creates. My problem is that we often create forms that mix HTML and CGI generated form elemenets (in Template Toolkit, for example).

One fix is to always use's methods to create form elements. Another is to never use them. A really bad solution is to try to set tab index around them. I don't really like any of these solutions. Any other suggestions on a work-around?

Also, has anyone else run into this? Should I suggest a pragma to turn this off again? Thanks.

Update: The workaround suggested below to use the -no_xhtml pragma only works for some CGI generated HTML. Some form elements will output the tabindex with xhtml activated or not.

Update:This has been fixed in the newest version of the CGI module. The tabindex feature is now an option and you must explicitly turn it on to make it work. The default behavior is now as it was before. Thanks to Lincoln Stein for fixing this.

Replies are listed 'Best First'.
Re: Tab index feature added to
by gellyfish (Monsignor) on Sep 07, 2005 at 19:31 UTC

    A quick workaround might be to use the -no_xhtml pragma that appears to disable the tabindex attribute on the form elements.


      Indeed you are correct. A quick look at the code reveals many statements like:
      return $XHTML ? qq(<input type="submit" tabindex="$tabindex"$name$val +$other />) : qq(<input type="submit"$name$val$other>);
      The side effect would be that we might not output xhtml, which we currently try to do, but this would be an easy fix for the tab order. I'm guessing we could still output custom headers that indicate the document is XHTML. Thanks for the suggestion.
Re: Tab index feature added to
by Lexicon (Chaplain) on Jan 10, 2006 at 22:52 UTC
    Have you found any better resolution to this problem yet? I'm having the same issue. I generate all my elements with CGI, but I don't generate them in the same order that I print them. I'm considering setting all tabindex's to 0 which would effectively disable it.
      Actually, I put together a patch and sent it to Lincoln Stein. Once he saw the problem I was having, he proceeded to come up with a much better solution. He's since released it to CPAN.

      So if you get the new version of CGI (change log version 3.12), you'll notice that the tabindex behavior is now an option and the old behavior (no tabindex) is the default again. That should fix the problem. I've tested the new code, but haven't moved it through our system to production yet.

      Hope that helps.

        That would do it! Didn't realize it, but SUSE comes preinstalled with the ancient CGI 3.10. OK, maybe May 2005 isn't ancient, but still. Thanks!

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://489976]
Approved by ww
Front-paged by ww
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (5)
As of 2020-05-28 21:29 GMT
Find Nodes?
    Voting Booth?
    If programming languages were movie genres, Perl would be:

    Results (166 votes). Check out past polls.