If your DataPage has a very long series of input fields, some of which may not apply to every end-user, you can divide your DataPage into sections and hide or show them when needed. This method can be used on Submission Forms, Update Forms, search and details pages of Reports, as well as Password Recovery Forms. This method cannot be used on Results page of Reports.
In this article, you create collapsible sections using toggle buttons in a Submission Form. It first explains how to add these sections to an existing Submission Form and then how to add buttons to toggle visibility. You can also configure your DataPage sections to display based on received parameters.
Note: The implementation method in this article requires you to disable the HTML editor from your HTML blocks. See how to disable the HTML editor and repeat this step for all the HTML blocks that are used in this method.
Add HTML blocks to surround sections in a Web Form
1. Navigate to the DataPages listing, select the DataPage you wish to add collapsible sections and click Edit. Proceed to the Configure Fields screen. Add an HTML Block to separate each section. Using the Insert button, at the lower right-hand corner of the DataPage Elements panel, insert an HTML Block.
Using the arrow buttons below the DataPage Elements panel, move the fields that will be included in the first collapsible section below this first HTML block. Then use the Insert button to add another HTML Block. This HTML block will serve both as the end of the first section and the beginning of the second. Move the appropriate fields to the second section and repeat the process until all of the sections have been marked out by HTML Blocks.
2. Next, create tables to encapsulate the section fields. To hide the separate sections, create HTML tables and set their visibility to ‘none’. In the first HTML Block create an HTML table tag. Set its id attribute to “Section1” and set its style attribute to “display:none”. Immediately after the table tag open a table data (td) tag.
Go to the second HTML Block. Close the table data tag and then close the table tag. If you were to preview the DataPage now, this first section would not be visible. In the second HTML block create a new HTML table and table data tag, but this time set the table id to “Section2”. The second set of tags will be closed in HTML Block number three. Repeat this process until all of the sections are enclosed in HTML table tags.
3. Now, you can create buttons to toggle visibility. The tables we created are currently hiding all of the fields. In the gaps between the tables, create buttons to toggle the section’s visibility. Before the opening HTML table tag in each HTML Block add an input tag with the type button. Replace the onClick attribute with a function called “Displayer()”. In the parenthesis after Displayer enter the number of the current section, e.g. Displayer(1) . Set the value attribute of the button to the section title. The value attribute will be the text displayed on the button.
Note: Instead of buttons you can use another HTML objects such as a links or images. Simply add Displayer as the onClick funtion to that object.
If you are looking to display an image instead of a button replace the code in the HTML Block :
<input type="button" onClick="Displayer(1)" value="Personal Info"> with <img src="IMAGE URL " onClick="Displayer(1)" >
where IMAGE URL is the URL of the image uploaded on your server.
4. Now, you add the Displayer function to the footer. Using the Insert button, select Header & Footer to add these sections. In the Footer, go the Source mode and insert the Displayer function. The Displayer function is written to accept an unlimited number of sections as long as the number passed to the function corresponds to the name of the section. (e.g. 4 is passed to toggle the visibility of section4).
5. Click Finish.
Testing and Formatting
By default, all of the sections we created will be hidden. You can change a section’s default visibility by setting the HTML table’s style attribute to “display:inline;” instead of “display:none;”.
If you would like to add columns to this DataPage, use the Insert button to add a New Section just after the first HTML Block. Change the column number as desired. Before the closing HTML Block add another New Section and reset the column number to one.
Advanced: Using Parameters to dynamically hide sections
You can also dynamically hide sections using received parameters
- Be sure to enable Advanced Options and Parameters for this DataPage to receive parameters.
- Create the HTML Block / HTML tables structure as before. In the footer, insert a duplicate of the following code for every section in your DataPage. Replace the section number as needed. Make sure that all of the code is surrounded by script tags.
- Next, replace the Parameter name with the parameter you are receiving. Make sure the parameter is formatted correctly: [@xxxxx] and is surrounded by single quotes. Also change the value to match the value expected. If the received parameter’s value matches the expected value, the section will be visible.