I have multiple text boxes now I want to find minimum value from them in a text box as result.
I have this working when I click the button, I need this to update when a change is made in any of the textboxes though not using the onclick event. How do I do that?
function minimum() {
var a = document.getElementById("1").value;
var b = document.getElementById("2").value;
var c = document.getElementById("3").value;
var d = document.getElementById("4").value;
var m = Math.min(a, b, c, d);
document.getElementById("5").value = m;
}
<input type="text" class="a1" id="1" value="1" />
<input type="text" class="a1" id="2" value="2" />
<input type="text" class="a1" id="3" value="3" />
<input type="text" class="a1" id="4" value="4" />
<input type="button" onclick="minimum()" value="MIN" />
<br /><br />
<input type="text" class="a2" id="5">