【发布时间】:2019-08-10 19:15:51
【问题描述】:
我有一个单选按钮(是,否)和输入文本框。 如果用户按否,输入字段将被禁用,并且 jquery .triger('change') 用于 ajax 表单提交(其中我已启动 ajax
$('#form-id').change(function(){
....
});
具有上述功能)
但是,当检查是的,输入就会变得活跃,用户可以输入值并按照往常按下提交按钮。上面的 ajax 更改功能很好地检测到用户将键入并失去焦点时的更改。所以这部分没有问题。
我的问题是当用户勾选 no 时,php 表单提交中的 isset($_post['radio_no']) 参数显示为空白。相反,我需要显示 value='No'。
我所有的努力都在进行。谁能帮帮我。
我的 Jquery
$(document).ready(function () {
$('input').on('ifClicked', function (event) {
var value = $(this).val();
if(value=='No'){
$(this).closest('body').find("input[data-value=" + this.name + "][type=text]").prop('disabled', true);
$(this).closest('body').find("input[data-value=" + this.name + "][type=text]").val('0').trigger('change');
} else {
$(this).closest('body').find("input[data-value=" + this.name + "][type=text]").val('');
$(this).closest('body').find("input[data-value=" + this.name + "][type=text]").prop('disabled', false);
}
});
});
【问题讨论】: