1
0
-1
Hi,

We are developing a form which has a block element, which will be populated by XML being injected into the form - is it possible to use one of these fields to dynamically build a drop down box which would be used to hide/show those sections of the page?
E.G:
Number (drop down box, shows 1,2,3)

[Repeat block]
[block1]
My Number = 1
Other data
[/block1]
[block2]
My Number = 2
Other data
[/block2]
[block3]
My Number = 3
Other data
[/block3]
[/Repeat]


Thanks
Richard
  1. Doug Oldmeadow
    Hi Richard,

    Have you looked at the populating drop down box from repeat widget ? I haven't used it before, but just did a test with it, you point it at the value and display fields in the repeating group and it will be populated. You'll then need a business rule to detect drop down events then loop through the repeat for matching value and hide/show from there.
    good luck
    Doug O
  2. Chantal Thomas
    Hi Richard,
    Please see the JavaScript API for the following functions:
    sfc.addListItem(noderef, value, display)
    sfc.clearListItems(noderef)
    sfc.addListItems(noderef, valueArray, displayArray, removeExisting)
    sfc.getListItems(noderef)

    Please note that we do not have functions to remove a single entry from a drop down list so you will need to clear the list and re-add all entries, sfc.getListItems() will assist in making this an easy script to do.

    As far as the question, you could use a business rule that triggers from the repeating block and getting the number of instances and sfc.getListItems() to work out if you need to add or clear you can create the new content for the dropdown.
    Regards
    Chantal
  3. Richard Mortimer
    Hi Doug,
    >Have you looked at the populating drop down box from repeat widget
    This sounds like what I want - do you know of any documentation that might give me a bit more detail?
    Cheers
    Richard
  4. Richard Mortimer
    Hi Doug,
    That's brilliant!! I never saw this control before, but it's exactly what I need. Thanks so much ...
    Cheers
    Richard
CommentAdd your comment...

1 answer

  1.  
    1
    0
    -1
    1. Doug Oldmeadow
      Hi Richard,
      I can't find any doco, but I knocked up a demo. It was easier than I thought - I just made a visibility rule on the repeating block - it the instance in the repeating group matched the dropdown, it becomes visible.
      See demo source here: https://gist.github.com/anonymous/7b7a0ca57be2a4ea25cc
      You can paste it into the XML source in composer and see it work.
      Cheers
      Doug O
    CommentAdd your comment...