How to create a TOC (table of content) within a repeat group?

mirceat

Member
Hello,

I have a form with a repeat group that can be repeated over 20 times within form. The form is having over 20 elements, so in the end i will end up with a very long form and very hard to use.

I used Sourcerer plugin to create a TOC in form but i can't make it work using anchors or, better says, nothing happen when i click on the links, the page doesn't scroll down at the group. Please note that i don't need to shows the TOC on the fly, it's ok to be updated every time i load the form.

snippet of code using sourcerer used in Group Intro:
PHP:
{source}
<?php
...$myQuery here..
$ancore = $db->loadObjectList();
echo '<ol>';
foreach ($ancore as $ancora) {
echo '<li><a href="#id'.$ancora->id.'">'.$ancora->ab.'</a></li>';
}
echo '</ol>';
?>
{/source}

and in form i have a calc element that gets the record id using calc on load:

Code:
$id = (int)'{contracte_servicii_21_repeat___id_raw}';
//return '<div id="id'.$id.'"></div>'; //tried with id for html5, no changes
return '<a name="id'.$id.'"></a>';

What i'm doing wrong here?

Thank you
 
And what in your TOC?

(and yes, you should better use //return '<div id="id'.$id.'"></div>'; //tried with id for html5, no changes..)
 
Code:
<ol><li><a href="#id15">Abonament Voce Mobila</a></li><li><a href="#id18">Abonament Voce Fixa</a></li></ol>

My understanding of using anchor is when i click on a link, the page should scroll down to that anchor..it doesn't happen here. I'm using the default bootstrap template.
 
It's working on my site (with <div id="subgr1"...)
Maybe idX is not unique?
Try something "unusual" like "tocgroupX"
 
idX is unique, also tried with tocgroupX, same problem, it doesn't scroll to the anchor. Did you test it in a repeat group, so the anchor belongs to the second or third instance of the repeated group?

Update (i cannot post a new reply): @troester, can you confirm: it doesn't work if the calc element is set to hidden, but it works if it's visibile?
 
Last edited:
We are in need of some funding.
More details.

Thank you.

Staff online

Members online

Back
Top