PHP では、$$variable を使用して文字列を変数に変換できます。
この JavaScript コードを変更したいと思います。
$( function () {
$("a#toggleBoxes_B").toggle( function() {
$("input[name=B0]").attr('checked', 'checked');
$("input[name=B1]").attr('checked', 'checked');
$("input[name=B2]").attr('checked', 'checked');
$("input[name=B3]").attr('checked', 'checked');
$("input[name=B4]").attr('checked', 'checked');
...
$("input[name=B29]").attr('checked', 'checked');
return false;
}
});
の中へ:
$( function () {
$("a#toggleBoxes_B").toggle( function() {
for (var i=0; i<30; i++) {
$("input[name=B[i]]").attr('checked', 'checked');
}
return false;
}
});
しかし、うまくいきません。
どうやってやるの?