nickboy
nickboy

Reputation: 36

can't pass value from form to php page

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">

image 1

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

Answers (1)

DPAMonty
DPAMonty

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

Related Questions