テーブルをループして(最初は非表示)、要求されたセクションに応じて特定の行を表示するために使用される配列を作成しました。
var rows_per_section = [ {min: 0, max: 7}, {min: 7, max: 17}, {min: 17, max: 21}, {min: 21, max: 35}, {min: 35, max: 41}, {min: 41, max: 46}, {min: 46, max: 52},{min: 52, max: 56} ];
var rows_min = rows_per_section[section_no].min;
var rows_max = rows_per_section[section_no].max;
テーブルの長さを変えることができるため、テーブルを循環し、rows_per_section 配列を独自に作成する追加の関数を使用して、スクリプトを変更しようとしています。クラスタグを探すことでテーブルのブレークを検出できますが、ブレークに達するたびに配列を作成して新しい値を追加する方法がわかりません。
function create_section_array(profile_table, no_of_sections) {
var section_counter = 0;
var rows_per_section = new Array(); //this is where it starts to go wrong
//need to create the array and stick in the
//MIN value for the first section as 0
for (i=0;i<profile_table.length-1;i++) {
var table_row = profile_table.item(i);
var row_content = table_row.getElementsByTagName("td");
if(row_content[0].className == "ProfileFormTitle") {
if(section_counter != 0) {
//if not the first section add a MAX value to
//rows_per_section[section_counter + 1]
}
if(section_counter != no_of_sections) {
//if not the last section add a MIN value to
//rows_per_section[section_counter]
}
section_counter++;
}
}
return rows_per_section;
}