The code create a variable for each field, obtaining the value from the field ID
it then tests to see if there is a null entry, if there is, it does nothing, is there isn’t a null entry, it than places that value into an array.
It checks each field building the array as it goes.
it gets to the end, performs a check to obtain the minimum number, writes that to a variable and then updates the field that is meant to contain the minimum number from the array.
Hope this helps someone out in the future.
var c1a;
var c2a;
var c3a;
var c4a;
var c5a;
var c6a;
var c7a;
var c8a;
var c9a;
var minca;
const check_age = []
c1a = document.getElementById('input_19_29').value;
c2a = document.getElementById('input_19_30').value;
c3a = document.getElementById('input_19_31').value;
c4a = document.getElementById('input_19_32').value;
c5a = document.getElementById('input_19_33').value;
c6a = document.getElementById('input_19_34').value;
c7a = document.getElementById('input_19_35').value;
c8a = document.getElementById('input_19_37').value;
c9a = document.getElementById('input_19_38').value;
if(c1a == "" ){
}
else{
const count = check_age.push(c1a)
}
if(c2a == ""){
}
else{
const count = check_age.push(c2a)
}
if(c3a == ""){
}
else{
const count = check_age.push(c3a)
}
if(c4a == ""){
}
else{
const count = check_age.push(c4a)
}
if(c5a == ""){
}
else{
const count = check_age.push(c5a)
}
if(c6a == ""){
}
else{
const count = check_age.push(c6a)
}
if(c7a == ""){
}
else{
const count = check_age.push(c7a)
}
if(c8a == ""){
}
else{
const count = check_age.push(c8a)
}
if(c9a == ""){
}
else{
const count = check_age.push(c9a)
}
minca = Math.min(...check_age);
document.getElementById('input_19_99').value = minca;
-
This reply was modified 4 years, 8 months ago by gingerstu.