Reputation: 36
I'm trying to pass a variable from a number input to a php page.
HTML CODE
<input type="number" class="count count-disco" name="quantita_cialda_disco" autocomplete="off" placeholder="0">
PHP and JQUERY CODE
$quantita_cialda_disco = $_POST['quantita_cialda_disco'];
echo $quantita_cialda_disco;
$('.count-disco').prop('disabled', true);
$(document).on('click','.plus-disco',function(){
$('.count-disco').val(parseInt($('.count-disco').val()) + 1 );
if ($('.count-disco').val() == 0) {
$('.count-disco').val(1);
}
calcPrice();
});
$(document).on('click','.minus-disco',function(){
$('.count-disco').val(parseInt($('.count-disco').val()) - 1 );
if ($('.count-disco').val() == 0) {
$('.count-disco').val(0);
}
calcPrice();
});
I manage the number field with + and -, I also attach the jquery.
I really don't understand why I can't pass the value.
many thanks in advance.
Upvotes: 0
Views: 53
Reputation: 181
Use $('.count-disco').prop('readonly', true);
instead of $('.count-disco').prop('disabled', true);
. Disabled fields are removed from form parameters when it is submitted.
Upvotes: 1