gpt4 book ai didi

javascript - 复选框问题

转载 作者:行者123 更新时间:2023-11-30 20:35:14 24 4
gpt4 key购买 nike

我正在尝试从 Kendoui Checkbox 中获取值,但到目前为止没有成功。

<input type="checkbox" id="telephonyeq1" name="telephonychk[]" class="k-checkbox telephonycb">

脚本

<script>
if($('#telephonyeq1').is(":checked"))
{
var telephonycb = "true"
}
else {
var telephonycb = "false"
}
</script>

当我通过 AJAX 发布数据时,我总是收到“假”值,即使它已被选中或未被选中。

Telephony: false 

还有 Ajax

        $("#save").click(function() {
$.ajax({
url: "/test",
method: "post",
data: {
.....
"telephonycb": telephonycb,
"internetcb": internetcb,
"_token": "{{ csrf_token() }}"
},
success: function(data) {
if($.isEmptyObject(data.error)){
printSuccessMsg(data.success);

} else{
printErrorMsg(data.error);
}
}

});

});
function printErrorMsg (msg) {
......
}
function printSuccessMsg (msg) {
$(".print-error-msg").find("ul").html('');
$(".print-error-msg").css('display','none');
$(".print-success-msg").css('display','block');
$("h5 span").html(
'<br /><h5><strong>Incident Description</strong>
.......
'</code><br /><h5><strong>Impact on Services</strong></h5>Telephony: <code>' + telephonycb + '</code> Service Issues <code>' + telephony.value() + '</code> - Affected Users: <code>' + telephonyaffected.value() +
'</code><br />Internet: <code>' + internetcb + '</code> Service Issues <code>' + internet.value() + '</code> - Affected Users: <code>' + internetaffected.value() +
......
);

}

});
</script>

最佳答案

更新ajax里面的行

"telephonycb": (($('#telephonyeq1:checked').length > 0) ? "true ": "false"),

关于javascript - 复选框问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49915340/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com