Colleagues.
I have a select from which you are bringing the stocks from a database. I'm capturing it this way:
<select name='estoque' id='estoqueProdutos'>
<option value='1'>1</option>
<option value='2'>2</option>
<option value='3'>3</option>
</select>
JQuery
function alterar(){
var estoques = $('#estoqueProdutos').val();
var estoque = document.getElementById("estoque").value = estoques;
}
Each stock will limit the quantity of the button below:
Itisrepresentedasfollows:
$('.value-plus1').on('click',function(){varestoqueProduto=document.getElementById("estoque").value;
var divUpd = $(this).parent().find('.value1'), newVal = parseInt(divUpd.text(), 10)+1;
if(newVal <= estoqueProduto){
document.getElementById("quantidade").value = newVal;
divUpd.text(newVal);
}
});
$('.value-minus1').on('click', function(){
var divUpd = $(this).parent().find('.value1'), newVal = parseInt(divUpd.text(), 10)-1;
if(newVal>=1){
divUpd.text(newVal);
document.getElementById("quantidade").value = newVal;
}
});
So far so good, the problem is that by selecting the value 3 and then the value 2, the value 3 continues to appear. I would like you to change the stock value, the quantity number back to the number 1.