Example.

The adjustment is as follows:

  • I enter the value <0.23 into another input output 1.4.
  • I enter the value <0.33 to another input output 1.6
  • I enter the value <0.43 into another input output 1.8.
  • I enter the value <0.53 into another input output 2

    2 answers 2

    var one = document.getElementById('one'), two = document.getElementById('two'), res; one.addEventListener('keyup', function() { var n = one.value; if (n < .23) { res = 1.4; } else if (n < .33) { res = 1.6; } else if (n < .43) { res = 1.8; } else if (n < .53) { res = 2; } else { res = 'out of range'; } two.value = res; }, false); 
     <input id="one" /> <input id="two" /> 

    • Thank you. - Big Daddy

    In general, the problem is solved as follows: https://jsfiddle.net/0439r4js/

     elem1.oninput = function() { var val = document.getElementById('elem1').value; document.getElementById('str').innerHTML="Вы ввели: "+val*0.3; }; 

    Only in the example I multiply any value by 0.3, and if you add and can multiply or divide by what you need.

    • I need if the value is less than 0.33, then it outputs 1.6 to the input, or if the value is less than 0.33, then it outputs 2, there are no calculations here. - Big Daddy
    • Well then innerHTML = "You have entered:" + "0.33"; for example, and if you do it yourself - RoboNoob