我想将数据返回到复选框。如果选中复选框的数据等值。 数据返回是json和脚本复选框不起作用。请帮我!!!! 防爆。 如果返回com_cate = 1
选中复选框
此代码自动完成。
<script type="text/javascript" src="js/js-autocomplete/js/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="js/js-autocomplete/js/jquery-ui-1.8.2.custom.min.js"></script>
<script type="text/javascript">
jQuery(document).ready(function(){
$('.company_name').autocomplete({
source:'return-company.php',
//minLength:2,
select:function(evt, ui){
this.form.id_company.value = ui.item.id_company;
this.form.com_contact.value = ui.item.com_contact;
this.form.company_address.value = ui.item.company_address;
this.form.id_contact.value = ui.item.id_contact;
this.form.company_tel.value = ui.item.company_tel;
this.form.company_fax.value = ui.item.company_fax;
this.form.mobile.value = ui.item.mobile;
this.form.company_email.value = ui.item.company_email;
this.form.com_cate.value = ui.item.com_cate;
/*check box */
if (this.form.com_cate.value == "1") {
$('.com_cate').prop('checked', true);
} else {
$('.com_cate').prop('checked', false);
}
}
});
});
</script>
<input type="checkbox" name="com_cate" id="com_cate" class="com_cate" value="1">
答案 0 :(得分:-2)
if (this.form.com_cate.value == "1") {
Print '<input type="checkbox" name="com_cate" id="com_cate" class="com_cate" value="1" checked="yes">'
} else {
Print '<input type="checkbox" name="com_cate" id="com_cate" class="com_cate" value="1">'
}
简单的解决方案?只需将您的JS更改为PHP!