I have a document with multiple section headings using alpha-numbering (A, B, C, etc.). Is there a way to create an automatic numbering method so that if some sections are hidden or revealed by user choices the sections renumber automatically? (i.e., if Section D becomes hidden, I want Section E to change to Section D, and so on, just like heading numbers in MS Word.) I'm attaching a screenshot of a sample section header here. I've looked up info on floating fields but haven't been able to figure out how to make them work. Thanks for any help!
Views
Replies
Total Likes
Hi,
This will depend on your form structure, is each section in a repeating group, or are you using a subformset?
If not and each section is a independent subform then you can calculate it's position, using classIndex and classAll, with code like;
var visibleIndex = 0;
for (var i = 0; i < parent.classIndex; i++) {
var section = parent.classAll.item(i);
if (section.presence == "visible") {
visibleIndex++;
}
}
This code assumes it's parent is the section subform, which you might need to change. Here's a sample with this code working https://sites.google.com/site/livecycledesignercookbooks/home/NumberedSections.pdf?attredirects=0&d=...
Bruce
Views
Replies
Total Likes
Hi Bruce,
Amazing; I could never have figured that out. I created a floating field called "SectionNumAuto" at each position where I need the number, and added your script to the "calculate" event for each instance. The script works, except that on the second page and subsequent pages, the first heading on each page has an "@" for the number, and then numbering starts again at "A". I tried adding "form1" and "parent" in front of the "parent" property in the script, but it didn't work. I also tried the changes below, and just couldn't get it to work:
var visibleIndex = 0;
var hCount = parent.SectionNumAuto.classIndex
for (var i = 0; i < hCount.value; i++) {
var section = parent.classAll.item(i);
if (section.presence == "visible") {
visibleIndex++;
}
}
Thanks for the help, as always.
Views
Replies
Total Likes
I forgot to include in my previous reply: these are independent subforms, not automatically generated or anything like that. The numbering seems to work even if a page extends onto a second page due to large content in expanding fields, but as soon as the next actualy page starts, the numbering goes back to "@" and the "A, B, C....". It seems the counter doesn't retain its value when going to a new page. I tried many ways to fix it, but I don't understand the properties well enough.
Views
Replies
Total Likes
Hi,
The code wont be effected by which pages the subforms fall on just the order they appear in the hierarchy within their parent subform. The "@" is the ascii character before the "A" character so you might need a "+ 1" somewhere. Happy to have a look if you can add a link to your form into this thread,
Bruce
Views
Replies
Total Likes
Thanks for offering, I'll have to look into that because it's for a government agency; not sure if they allow it to be distributed. I'm kind of stumped, because the numbers reset only when it goes to a new form page.
Views
Replies
Total Likes
Hi Bruce,
I found out I can't post the form here, but I can send it to you for review -- any way I can do that?
Thanks,
Kam
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies