What you're looking for is calling the focus
of an element. For example:
var select = document.querySelector('select');
select.addEventListener('change', function() {
var input = document.querySelector('input[name="' + this.value + '"]');
if (input) input.focus();
});
jsFiddle: link
In this example each time the select changes it will look for an input with the name that was selected in the select. If you find it puts it in focus .
For cases where you have a limit in the input just count the size of the string in the input and move to the next input when this condition is verified. An example would be:
var inputs = document.querySelectorAll('input');
[].forEach.call(inputs, function(el) {
if (el.dataset && el.dataset.length) {
var max = parseInt(el.dataset.length, 10);
el.addEventListener('keyup', function() {
if (this.value.length >= max) focusNext(this, inputs)
});
}
});
function focusNext(el, els) {
var match;
for (var i = 0; i < els.length; i++) {
if (match) {
els[i].focus();
break;
}
match = els[i] == el;
}
}
jsFiddle: link