Setting ui_choicelist value

fraser_thomson
Kilo Explorer

Hey guys,

 

I'm currently creating a UI page and using <g:ui_choicelist>, the parameters I have are name, table and field.

I was wondering if there was a way to set the value of this choicelist? It always defaults to the first in sequence?

 

Thanks

1 ACCEPTED SOLUTION

Anurag Tripathi
Mega Patron
Mega Patron

Hi Fraser,



I have a ui page where i did create a dropdown, its the simple HTML code and its working just fine:


<select id="approvers" onchange="test()" style="width:200px">


<option value=''> -- None --   </option>


<option value='a'> A   </option>


<option value='b'> B   </option>


</select>


-Anurag

View solution in original post

17 REPLIES 17

Anurag Tripathi
Mega Patron
Mega Patron

Hi Fraser,



I have a ui page where i did create a dropdown, its the simple HTML code and its working just fine:


<select id="approvers" onchange="test()" style="width:200px">


<option value=''> -- None --   </option>


<option value='a'> A   </option>


<option value='b'> B   </option>


</select>


-Anurag

Hi Anurag,



Thank you for your reply.
I am trying to use the choicelist(s) defined on a table elsewhere, I have considered manually creating an HTML drop down but using ui_choicelist would save me some lines of code for that as there will be a few!


in my code also the choice values are not hardcoded, its coming from db only...here is the full code



<g:evaluate jelly="true" object="true">


        var GR = new GlideAggregate("<table name>");


        GR.addQuery("<field name>", '${sysparm_sysID}');


        GR.groupBy("<field name>");


        GR.query();


      </g:evaluate>



<tr align="center">


<td id="description" align="right" >Select Approval Name:</td>


<td id="approvers" >




<select id="abc" onchange="test()" style="width:200px">


<option value=''> -- None --   </option>


<j:while test="${GR.next()}">


    <option value = "${GR.<field 1>},${GR.<field 2>}" > ${GR.<display field>} </option>


</j:while>



  </select>


  </td>


        </tr>


-Anurag

Thanks, I've tried using the HTML select just to see if it works.
Only problem is <option value="" selected> </option> doesn't seem to be working, does Jelly not support preselected values for the dropdowns?