【发布时间】: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。
我真的不明白为什么不能传值。
非常感谢。
【问题讨论】:
-
您的
<form>标签是否包含method="post"属性? -
@KIKOSoftware 是的,我尝试使用其他变量,它可以工作
-
而
<input>标签在<form>....</form>标签内?很抱歉这些问题,但您在问题中的表单代码不完整。 -
@KIKOSoftware 对不起,如果我没有把整个表格,但它真的很长。是的,绝对是,它在表单标签内。
-
哦,我看到您禁用了该字段。尝试改用
readonly="true"。参数集合中不包含禁用的字段。