aboutsummaryrefslogtreecommitdiff
path: root/content/post/2008-10-11-tabbing-through-fields-vertically.markdown
blob: 2ca859d31b8b94ec664adc3f3c7557b0d97849eb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
---
layout: post
title: "Tabbing through fields vertically"
date: 2008-10-11T01:54:00Z
comments: false
url: /post/54058512/tabbing-through-fields-vertically
tags:
---



Sometimes it’s useful to switch the browser’s default tabbing behavior (left to right) to the opposite (top to bottom) when your input fields are in a grid layout instead the of the usual single column layout. Having to do this manually is a real pain, especially for large grids; So here is a solution in javascript, using mootools:

```javascript
window.addEvent('domready', function(){
    var trs = $$('#mytable tr')
    var accum = 0
    trs.each(function(tr, trindex){
        accum = trindex + 1
        tr.getChildren().each(function(td, tdindex){
            td.getChildren('input')[0].tabIndex = accum
            accum = accum + trs.length
        })
    })
})
```