<html>
<head></head>
<input id="one" />
<input id="two" />
<body>
<script>
input1=document.querySelector("#one")
input2=document.querySelector("#two")
base=10
calc=function(){
var another
switch(this){
case input1: another=input2; break
case input2: another=input1; break
}
another.value=base-this.value
}
input1.oninput=calc
input2.oninput=calc
</script>
</body>
</html>