In a ui page, how do you populate a "list" UI element in a UI page with values?

reanimate
Tera Contributor

the html is:

<g:ui_element table="u_development_standard" field="u_standard" id="466eef750fd3710060017e4ce1050ee2"></g:ui_element><p></p>

the javascript to GET the value is:

var standardId = gel('u_development_standard.u_standard');

but how do I SET the value?

1 ACCEPTED SOLUTION

If you're starting off with an empty list and you want to add to it, you should also see a "_edit" which you're probably aware of since that is the element that contains your actual glide-list and you needed to change the display value to get it to show. Or at least that's what I get and had to do.



So inside of that you'll see the list is actually a simple select element that if not empty would contain option elements. If you want to add/remove to that then you need to do the same as before and capture it via DOM.


I believe the id for the select element would be something like this "select_0u_development_standard.u_standard".


So document.getElementById('select_0u_development_standard.u_standard') should do it. From there you'll need to create an element and stuff it with the desired data. Then append it to the select element. Something like this:




var selEl = document.getElementById('select_0u_development_standard.u_standard');


var optEl = document.createElement('option');


var txtNd = document.createTextNode([your display value if different from actual value]);


optEl.setAttribute('value', [your actual value. usually the sys_id]);


optEl.appendChild(txtNd);


selEl.appendChild(optEl);




All of those values should correlate to what you already have going on with the previous stuff. Of course you can optimize the code so that you can add multiple at a time. I'll leave that up to you though.






View solution in original post

11 REPLIES 11

Fantastic, thanks so much I've pretty much sorted it and that's down to all your help.


Brilliant!


Community Alums
Not applicable

Could you share a example screenshot of this implementation? To check aspect, design, etc.