Here is one possible approach:-
Code:
<form id = "adminForm">
Basic <Input type = "text" id = "basic" onchange = "update(1)"><br>
Net <input type = "text" id = "net" onchange = "update(2)"><br>
Gross <input type = "text" id = "gross" onchange = "update(3)"><br>
</form>
<script type = "text/javascript">
var profitmargin = .25;
var vatrate = .2; // presumably these two values are constants
function update (x) {
var b = document.getElementById("basic");
var n = document.getElementById("net");
var g = document.getElementById("gross");
if (x==1) {
b.value = (b.value*1).toFixed(2);
n.value = (b.value * (1 + profitmargin)).toFixed(2);
g.value = (n.value * (1 + vatrate)).toFixed(2);
}
if (x==2) {
n.value = (n.value*1).toFixed(2);
b.value = (n.value / (1 + profitmargin)).toFixed(2);
g.value = (n.value * (1 + vatrate)).toFixed(2);
}
if (x==3) {
g.value = (g.value*1).toFixed(2);
n.value = (g.value / (1 + vatrate)).toFixed(2);
b.value = (n.value / (1 + profitmargin)).toFixed(2);
}
}
</script>
Note that forms should be assigned an id, not a name which is now deprecated and obsolete. Form elements should be referenced by id.
Quizmaster: "I'm just going outside, and may be some time" were the last words of which explorer?
Contestant: Columbus