I have a string containing the section titles and page counts per section as follows:
string = "section1;section2;section3;section4|2 3 1 4"
i would like to be able to create a section index and use the titles as links to the appropriate pages in the whole document.
any suggestions? My initial thought was to split the string into the section headers and page counts, then split these and append the titles to a unordered list? That would take care of the section titles but what about the page counts?
var options = string.split('|');
var sections = options[0];
var section_titles = sections.split(';');
for (a=0;a<section_titles.length;a++){
$('ul').append('<li><div class="title">'+sections[a]+'</div></li>');
};
var counts = options[1];
var section_counts = counts.split(' ');
???????
Please send your suggestions.
Here’s what ended up working for me…