Allow user add more textfield


#1

Hello!

I’m trying to make a form that allow user add more than 1 textfield (“Type”) but maximal 5 textfield using “+” button. For now, I only can add 1 texfield

addForm.rp (56.8 KB)


#2

There are several ways you could do this. Here is an updated file showing two different approaches. On Page 2 I show a “brute force” approach, in which I duplicated the hidden dynamic panel (dp), and named them all “Dynamic 1” through “Dynamic 5”. On each “add button” press, the “next” dp is shown and the “next next” dp is moved into place.

On Page 3 I show a more extensible approach using a repeater widget. Each “add button” press adds a new row to the repeater. Because it looks like you need the “Type” fields grouped together, above the “kg” field, I’ve added a repeater column to track the order of the rows and sort the repeater on this column each time a new row is added. The easiest way to keep track of how many “Type” fields exist is with a global variable (I named, “countType”). This may all seem more complicated–and the initial setup is–but it allows flexibility to easily change the number and type of input fields added, if say, someone decides you need to add only 3 extra fields, or 20 extra fields, instead of 5. Also, whatever visual styling and code you might want to assign to the input fields only has to be done once in the repeater, instead of 5 different places–on each copy of the input field.

addForm.rp (140.0 KB)


#3

Perfect! I really appreciate it. Thank You


closed #4

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.