Adding loop to render form elements runtime in ui page html

IamAmolB
Tera Guru

Hi Experts,

Do anyone have any idea about, how can i add repeated form elements via loop

I have created ui page on that one reference field i want to be created runtime, anyone have any idea how can i do that?

Regards,

Amol Bavaskar

5 REPLIES 5

Kannan Nadar
Tera Guru

You can do that using javascript.



HTML:



<?xml version="1.0" encoding="utf-8" ?>


<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">


<div id="container"></div>


</j:jelly>



Client Script



var container = document.getElementById("container");
for (var i = 0; i < 3; i++) {
  container
.innerHTML += '<div class="box"></div>';
}


IamAmolB
Tera Guru

Hi kannan,



Can we do it Html itself because i have a table in html in which i am rendering the contents as below



<tr>


<td nowrap="true">


  <g:ui_reference name="assignment_group3" id="assignment_group3" table="u_rc_assignment_group_mapping" value="" onchange="checkAsignee(3)"/>



</td>


<td nowrap="true">


      <select id="assign_to3" name="assign_to3">


<option value="">---Select---</option>


</select>


</td>


      <td nowrap="true">


  <input name="notes2" id="notes2" value=" " />


</td>


</tr>



I want this tobe repeated in loophow can we do that?


Hi Amol,



I tried but the loop is not executing more than once. If I remove the reference field then it is getting executed properly. Not sure why 😕



Thanks,


Kannan


Mrudula6
Mega Guru

Hi Amol,



We can achieve this using the <j:while> (Jelly tag) in a UI page. Could you share a little bit more on the requirement.



Jelly Tags - ServiceNow Wiki