My code onclick for each checkbox function is:
function testc() {
var values1 = new Array();
jQuery.each(jQuery("input.id1"), function() {
values1.push(jQuery(this).attr("name"));
});
var values2 = new Array();
jQuery.each(jQuery("input.id76"), function() {
values2.push(jQuery(this).attr("name"));
});
//build arrays
var attname = "[name='"+values1[this]+"']"; //there should also be indexof clicked checkbox
jQuery("input:[type=checkbox]"+attname).attr("checked", true);
alert(values1.findIndex(jQuery(this).attr("name")));
}
What’s wrong? :/ I think the problem is how I’m getting indexes.
Ignoring issues of why you’re setting up the arrays like that and what you’re trying to do, I think the problem with the alert is that there isn’t a
findIndex()array method. Did you mean.indexOf():