I have about ten check boxes that each implement different functions. I am trying to make one master checkbox that will a) check all 10 checkboxes; b) implement the functions in each
I have gotten one to work but for some reason, when I check it, the others aren't checked until I move my mouse off of the master checkbox (after checking it). Bizarre, right? Here is the code for the master checkbox and the sub-checkboxes. (I have to warn you that I am a little new to javascript and it's possible that this is terribly written. Advice in that direction also welcome.)
/*change all buttons of a single genre*/
$("a[id^="+genre+"_]").attr("class", modereplacement+"Button" + " showButton");
$("a[id^="+genre+"_]").attr("onClick", function(index, currentValue){ return currentValue.replace(mode, modereplacement) ; });
$("#"+"all_"+genre+'_cur').attr("onClick",function(index, currentValue){ return currentValue.replace(mode, modereplacement) ; });
/*check all checkboxes*/
if (category =='All')
{
$("#"+"alls_cur").attr("onClick",function(index, currentValue){ return currentValue.replace(mode, modereplacement) ; });
for (var i = 0 ; i < 13 ; i++)
{
/*change individual buttons*/
var currentgenre = allgenre[i];
$("a[id^="+currentgenre+"_]").attr("class", modereplacement+"Button" + " showButton");
$("a[id^="+currentgenre+"_]").attr("onClick", function(index, currentValue){ return currentValue.replace(mode, modereplacement) ; });
/*change Quick button*/
$("#"+"all_"+currentgenre+'_cur').attr("onClick",function(index, currentValue){ return currentValue.replace(mode, modereplacement) ; });
$("#"+"all_"+currentgenre+'_cur').prop("checked", (mode == "offx"));
}
}
And here is the HTML that implements the 'Check All' aka 'Watch All' buttons:
<td><a class='quickButton'>Watch All</a></td>
<td><input type='checkbox' id='alls_cur' onclick=\"watchgenre( $user_id,'All','alls', 'offx', 1);\" ></input></td>
<td><input type='checkbox' $checkname id='alls_fut' onclick=\"watchgenre( $user_id,'All','alls', 'offx', 2);\" ></input></td>
Thanks for any advice you are able to give
Aucun commentaire:
Enregistrer un commentaire