function getBrand1(id)
{
// alert('Choose brands!');
if(document.getElementById(id).checked)
{
$.ajax({
url: 'http://localhost/partsanalysis/public/brand/Ajax/'+id,type: "GET",dataType: "json",error: function(data,errorThrown)
{
console.log('request failed :'+errorThrown);
},success:function(result) {
console.log(result);
// alert(result);
/* $.each(result,function(index,value) {
//alert(value);
// $("#brands").html('<input type="checkbox" />'+value );
var markup = "<tr><td><input type='checkbox' name='brand_id'></td><td>" + value + "</td></tr>";
$("#brands").append(markup);
}); */
$.each(result,value) {
//alert(value);
// $("#brands").html('<input type="checkbox" />'+value.brand_name );
var markup = "<tr><td><input type='checkbox' name='brand_id'></td><td>" + value.brand_name + "</td></tr>";
$("#brands").append(markup);
});
}
});
}
else
{
$("#brands").html("");
}
}
视图
<table id="brands">
<tr><td>
<input type="checkbox" name="brand_id"></td></tr>
</table>
请检查我的代码,当一个复选框被选中时我错了,它显示了多个复选框,在这种情况下,单击显示值但没有复选框