My html code:
<label for ="filter_AFFILIATION_1">
<input type="checkbox" id="filter_AFFILIATION_1" name="filter_AFFILIATION_1[]" value="1">ICSE
</label>
<label for ="filter_AFFILIATION_2">
<input type="checkbox" id="filter_AFFILIATION_2" name="filter_AFFILIATION_2[]" value="2">CBSE
</label>
<label for ="filter_AFFILIATION_3">
<input type="checkbox" id="filter_AFFILIATION_3" name="filter_AFFILIATION_3[]" value="3">State Board
</label>
<label for ="filter_AFFILIATION_4">
<input type="checkbox" id="filter_AFFILIATION_4" name="filter_AFFILIATION_4[]" value="4">ISC
</label>
My javscript code:
<script type="text/javascript">
$(document).ready(function() {
$("#filter_AFFILIATION_1").change(function(){
var data = {request : $('#filter_AFFILIATION_1').val()};
$.ajax({
type: 'POST',
url: Routing.generate('listingpage'),
contentType: 'application/x-www-form-urlencoded',
data: data,
success: function(result,status,xhr){
var div_options = document.getElementById("filter_AFFILIATION_1");
var inst_arr = JSON.parse(result);
var inst_val_arr = [];
for(var i = 0; i < inst_arr.length; i++){
inst_val_arr[i] = inst_arr[i];
var affiliation = inst_val_arr[i].instaffiliation;
document.getElementById('aff').innerHTML = affiliation;
if (document.getElementById('filter_AFFILIATION_1').checked){
$('#schooldata').html('');
}else if (!(document.getElementById('filter_AFFILIATION_1').checked)) {
alert('nothing');
}
}
},
error: function(xhr, status, error) {
console.log(status);
}
});
});
});
Here i am passing one checkbox id like filter_AFFILIATION_1 then i am getting this checkbox id result. How can i pass all check box id's (filter_AFFILIATION_1,filter_AFFILIATION_2,filter_AFFILIATION_3,filter_AFFILIATION_4) at a time above javascript code.
Please help me anyone Thanks for advance...
Aucun commentaire:
Enregistrer un commentaire