Expand my Community achievements bar.

How to connect choices in a form to an automatic table generation

Avatar

Former Community Member
Hi,



I've a complex form to create.



In this form, there is a part where users could select options for a table (eg: the numbers of rows, columns and sections in the table).

Then, the table is generated (on click ?).



I'm pretty sure, there is a way to do this but I'm not enough good as programmer to do this by myself.



On which event put my script ?

javascript or formcalc ?

As the table doesn't exist yet, how condition it ? (color of background ? Font ? etc.)



In fact, the table could exist...but ...



Users could select :

- 3 or 4 columns ;

- the numbers of rows ;

- The numbers and the place of sections (unless they (users in acrobat reader) could merge cells ???)



Is it really possible ?



I hope, I was clear in my explanations.



Thanks for ur help



Nath
1 Reply

Avatar

Level 10
Hi Nath,



I haven't a clue how you would programme a button to generate a table based on the user selecting the number of rows and columns. It probably can be done, but I don't know how!



However if there are only a few combinations for the number of columns, you could create the tables each in its own subform. Then the script would show and hide the subforms depending on the users input.



For example you could have a dropdown with the number of columns (2; 3; 4) which the user selects. On the exit/change event you could have script like:



if (this.rawValue == 2) {

form1.page1.subformContainer.subformTable2.presence = "visible";

form1.page1.subformContainer.subformTable3.presence = "hidden";

form1.page1.subformContainer.subformTable4.presence = "hidden";

}

if (this.rawValue == 3) {

form1.page1.subformContainer.subformTable2.presence = "hidden";

form1.page1.subformContainer.subformTable3.presence = "visible";

form1.page1.subformContainer.subformTable4.presence = "hidden";

}



// etc....



All subforms could initially be set to hidden. Each subform would be set to flowed and then all three subforms would be in a containing subform also set to flowed.



Dealing with the number of rows, each table could have one row with an add.instance button set to add additional rows. Because the table is already in a flowed subform, the user can add as many rows as you want to set.



If I was doing it, I would set up the table with the maximum number of rows first and get that working perfectly. Then I would duplicate that whole subform and rename.



Good luck,



Niall