【问题标题】:can't pass value from form to php page无法将值从表单传递到 php 页面
【发布时间】:2020-05-02 15:19:22
【问题描述】:

我正在尝试将变量从数字输入传递到 php 页面。

HTML 代码

<input type="number" class="count count-disco" name="quantita_cialda_disco" autocomplete="off" placeholder="0">

PHP 和 JQUERY 代码

$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();
               }); 

我用 + 和 - 管理数字字段,我还附加了 jquery。

我真的不明白为什么不能传值。

非常感谢。

【问题讨论】:

  • 您的&lt;form&gt; 标签是否包含method="post" 属性?
  • @KIKOSoftware 是的,我尝试使用其他变量,它可以工作
  • &lt;input&gt; 标签在&lt;form&gt; .... &lt;/form&gt; 标签内?很抱歉这些问题,但您在问题中的表单代码不完整。
  • @KIKOSoftware 对不起,如果我没有把整个表格,但它真的很长。是的,绝对是,它在表单标签内。
  • 哦,我看到您禁用了该字段。尝试改用readonly="true"。参数集合中不包含禁用的字段。

标签: php html jquery css


【解决方案1】:

使用$('.count-disco').prop('readonly', true); 代替$('.count-disco').prop('disabled', true);。提交时,禁用的字段会从表单参数中删除。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-05-12
    • 1970-01-01
    • 2015-08-21
    • 2017-11-16
    • 2013-11-23
    相关资源
    最近更新 更多