JSFiddle - React, Tailwind, and code Playground
HTML
<div id="container">
<form action="sample2.php" id="calculator" name="calculator" method="post">
<fieldset>
<legend>Input</legend>
V = <select name="V" id="V" tabindex="1" onchange="$('#calculator').submit();">
<option SELECTED value="1">1</option>
<option value="10">10</option>
<option value="100">100</option>
</select>
<br />
W = <select name="W" id="W" tabindex="2" onchange="$('#calculator').submit();">
<option SELECTED value="1">1</option>
<option value="10">10</option>
<option value="100">100</option>
</select>
<br />
X = <input name="X" id="X" type="text" tabindex="3" value="1" onChange="$('#calculator').submit();" />
<br />
Y = <input name="Y" id="Y" type="text" tabindex="4" value="1" onChange="$('#calculator').submit();" />
<br />
Z = <input name="Z" id="Z" type="text" tabindex="5" value="1" onChange="$('#calculator').submit();" />
<br />
A = <input name="A" id="A" type="text" tabindex="6" value="1" onChange="$('#calculator').submit();" />
<br />
B = <input name="B" id="B" type="text" tabindex="7" value="1" onChange="$('#calculator').submit();" />
</fieldset><br />
<fieldset>
<legend>Output</legend>
W+X+Y+Z+A+B = 6<br />
<span style="display:none">
shiftCatch = <input name="shiftCatch" id="shiftCatch" type="text" value="" /><br />
captured = <input name="captured" id="captured" type="text" value="" /><br />
recaptured = <input name="recaptured" id="recaptured" type="text" value="V" />
</span>
</fieldset>
</form>
</div>
JavaScript
$(document).ready(function() {
var elements = $("#container :input:visible");
var n = elements.length;
elements
.keydown(function(event){
if (event.keyCode == 9) { //if tab
var currentIndex = elements.index(this);
var newIndex = event.shiftKey ? (currentIndex - 1) % n : (currentIndex + 1) % n;
var el = elements.eq(newIndex);
if (el.attr("type") == "text")
elements.eq(newIndex).select();
else
elements.eq(newIndex).focus();
event.preventDefault();
}
}).eq(0).focus();
});