Debopriyo Dey

Debopriyo Dey

  • NA
  • 51
  • 15.1k

bind checkbos from database using jquery.

Sep 14 2017 1:58 AM
I have a checkboxlist as follows
 
<div class="form-group" id="chkbxSpeciality">
<p class="help-block" id="lblSpecialityErr" style="color: Red;">
</p>
</div>
 
and this is the js to bind data from database.
 
function BindSpecialityType() {
$.ajax({
type: "POST",
url: "MRRegistration.aspx/GetSpeciality",
data: {},
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (response) {
var objdata = $.parseJSON(response.d);
BindSpecialityCheckBoxList('chkbxSpeciality', objdata);
}
});
}
function BindSpecialityCheckBoxList(target, data) {
var table = $('<table></table>');
var counter = 0;
$(data).each(function () {
table.append($('<tr></tr>').append($('<td></td>').append($('<input>').attr({
type: 'checkbox', name: 'chklistitem', value: this.SPECIALITYID , id: target + counter
})).append(
$('<label>').attr({
for: 'chklistitem' + counter++
}).text(this.SPECIALITYNAME ))));
});
}
 
 
but i am not able to bind. Please help 

Answers (2)