I have a php loop that echos multiple <select>
elements as part of an online ordering system where the user can select the quantity of a certain item.
The button that executes the form runs a php script that inserts the values into my database, however, I need to be able to ignore the values that are equal to "0".
By creating an onClick event (JS function) on the submit button, I execute this code:
$('#quantityForm').find(':select').each(function(){
if($(this).val() == "0"){
$(this).attr('disabled', 'disabled');
}
})
Everything seems to work fine except the code that sets the <select>
element as disabled, as my php script attempts to get all of the "0" values.
Is there something I am doing wrong?
Additional code:
<form id="quantityForm" method="get">
<?php get_items($example); ?>
<button onClick="checkQuantity()" id='basket' type='submit' name='submit'><i class='fas fa-shopping-basket'></i></button>
</form>