I am having checkboxes in a table.Now to check which of the checkboxes are checked i wrote following code and i concatenate the values of these checked checkboxes seperated by a comma.But the code returns null value.
function myfun() {
var s="";
var flags = document.querySelectorAll('.select_all_mail');//Here this is class of checkboxes
for (var i=0, iLen=flags.length; i<iLen; i++) {
if (flags[i].checked) {
//here also its printing all the values of check boxes weather they are checked or not
console.out(flags[i].value);
s=s+flags[i].value+',';
}
}
s=s.substring(0,s.length-1);
//I want this s to pass to a servlet so i do following code
document.myinbox.hiddenValue.value = s; //here myinbox is name of form
document.myinbox.submit();
}
Is their something wrong with code?Please help