【发布时间】:2014-08-12 08:38:19
【问题描述】:
我有这些 checkboxes 我已经可以从它的表中获取值,但我只是不知道它会如何检查那些带有已插入我的数据库中的值的复选框。
function editPageLink(id){
$.ajax({
type : 'GET',
async : false,
data : {
key : id
},
url : baseUrl+'/admin/getdiscountinfo',
error: function(req,error){
notify('e',req.statusText);
},
dataType: 'json',
cache: false,
success : function(msg){
if(Object.keys(msg).length != 0){
newPage();
saveType = 'u';
key = msg[0].key;
$('#discountCode').val(msg[0].discountCode);
$('#discountName').val(msg[0].discountName);
$('#discountDesc').val(msg[0].discountDesc);
$('#discountType').val(msg[0].discountType);
$('#expiration').val(msg[0].expiration);
$('#expStartDate').val(msg[0].expStartDate);
$('#expEndDate').val(msg[0].expEndDate);
$('#discountValue').val(msg[0].discountValue);
$('#productId').val(msg[0].productId); if ('.chkbox2'.val() == true){
$('.chkbox2').check(checked); // i dunno if this is right.
};
$('#discounteTransaction').val(msg[0].discountTransaction);
}
}
});
}
我试过了,但还是不行。感谢您的帮助! :D
编辑:我的#productId 和'.chkbox2' 是一样的。是这部分,取值对吗?
$('#productId').val(msg[0].productId); if ('.chkbox2'.val() == true){
$('.chkbox2').check(checked);
};
【问题讨论】: