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
Giga 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>


View solution in original post

17 REPLIES 17

I have not tried the default select, but that you can order in the GR query using the gr.orderBy   function, and the virst value in the <option> tag becomes selected.


Thanks, the value I'm pulling is only going to be one field.
So


If the field on the other table is empty then it needs to default to <option>Select an answer</option> or if there is a value in the field on the other table then it needs to default to <option> $[value from field] </option>


try this attribute



selected="selected" in option


Hi Harikrishnan,
Thanks, I tried that after posting my reply earlier, forgot to mention it.


okay, i tried this one of the demo instances and it works perfectly:-



<html>


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


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


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


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


</select>


</html>



(I just used the code from one of the posts above)



If you need the selected value to be dynamic, I would say probably write a function onload of the page and then use dom to set the default value for the choicelist.



Regards,


Hari