Nathan Riley
asked on
Javascript Filter on Variable Set
I have the following code on my page that I need to apply some filters to:
The 2nd line:
I want to get all the elements by name of quantity but exclude the ones that have an ID of quantity2442 and quantity2443.
Is there a way to do this when setting the variable?
<script type="text/javascript">
function check() {
var elements = document.getElementsByName("quantity");
var qtycheck = document.getElementById("qtycheck").value;
for (var i=0; i<elements.length; i++) {
var nmbr = elements[i].value;
if (nmbr > <?php echo $maxqtyorder; ?>){
alert("You've selected more treats than your package allows.");
return false;
}
else if (nmbr > qtycheck){
alert("You've selected more treats than your package allows.");
return false;
}
}
return true;
}
</script>
The 2nd line:
var elements = document.getElementsByName("quantity");
I want to get all the elements by name of quantity but exclude the ones that have an ID of quantity2442 and quantity2443.
Is there a way to do this when setting the variable?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.