This script works as follows: If one of the 3 dropdowns has a grade lower than 8, it will show the contents of a% hidden_co%.
It works as follows:
- 1st dropdown has note
This script works as follows: If one of the 3 dropdowns has a grade lower than 8, it will show the contents of a% hidden_co%.
It works as follows:
It is not a beautiful solution as it is being forced to work with 3 values:
$('#privileges1').change(function(){validaValor()});
$('#privileges2').change(function(){validaValor()});
$('#privileges3').change(function(){validaValor()});
function validaValor() {
x = parseInt($('#privileges1').val());
y = parseInt($('#privileges2').val());
z = parseInt($('#privileges3').val());
if((x + y + z) < 24) { // 8 + 8 + 8
$('.resources').show();
} else {
$('.resources').hide();
}
}
Your code was not working because it was only considering the value of each select and not the value of the three.
EDITION
Fabio Henrique, I did not really foresee this situation so I suggest another solution, which is also not pretty because it forces the use of an X quantity of objects:
$('#privileges1').change(function(){validaValor()});
$('#privileges2').change(function(){validaValor()});
$('#privileges3').change(function(){validaValor()});
function validaValor() {
x = parseInt($('#privileges1').val());
y = parseInt($('#privileges2').val());
z = parseInt($('#privileges3').val());
if(x < 8 || y < 8 || z < 8) {
$('.resources').show();
} else {
$('.resources').hide();
}
}
In case you get another solution, please answer your own question, this problem seems very interesting to be solved in a more generic way and able to handle N objects dynamically, I will continue in search of a better solution. / p>