UI Page - How to programmatically create 10 input fields

Jim Coyne
Kilo Patron

I'll prefix this by saying I know just enough about Jelly to be dangerous.   I'm trying to add some text input fields on a UI Page.   Right now it's limited to 10 fields, but it may change to another number and I'm planning on switching it to a property later on, but just want to get this to work as is with a hard coded 10 items:

<j2:set var="jvar_serialnumbers" value="1" />

<j2:while test="$[jvar_serialnumbers != 10]">

      <tr class="item" id="extra_lines2_$[jvar_serialnumbers]">

              <td colspan="6"></td>

              <td colspan="2">

                      <label>Serial Number</label>

                      <input type="text" size="14"

                              name="serial_$[jvar_serialnumbers]"

                              id="serial_$[jvar_serialnumbers]"

                              value="serial_$[jvar_serialnumbers]"/>

              </td>

      </tr>

      <g2:evaluate var="jvar_serialnumbers" expression="jvar_serialnumbers=jvar_serialnumbers+1;" />

</j2:while>

I thought this should work, but only 1 field is being added.   I originally tried:

<j2:while test="$[jvar_serialnumbers ${AMP}lt; 10]">

on line 2 but it gives me the following error: Error at (125, 53): null:-1:-1: <null> Unable to create expression: jvar_serialnumbers < 10

Any help would be appreciated.

1 ACCEPTED SOLUTION

ChrisBurks
Mega Sage

Within the while loop the g2:evaluate should instead be another j2:set


<j2:set var="jvar_serialnumbers" value="$[jvar_serialnumbers + 1]"/>


View solution in original post

5 REPLIES 5

alebuc
Tera Expert

Hi,

 

I have used your idea to programmatically create 10 reference fields in my ui page.

Now I have to recall the contents of this fields in the processing script, how can I do?

 

Thanks,

Alessio