How Can I use multi select drop down choice list in UI page?

Reddy4811
Tera Expert

Dear all, @Ankur Bawiskar 

Please give me any suggestions for below requirement. 
 
My requirement is, I need to select the multiple options from multi select dropdown list. I can select the multiple options in dropdown but those selected multiple options are not showing in the field.
 
 
example code:-
****************************************
 
<section>
<g:evaluate jelly="true" object="true" var="jvar_arr">
var arr = gs.getProperty(instances').split(','); // give the property name here
arr;
</g:evaluate>
<div class="input-block input-col">
<div class="field-label1"> <span class="asterisk">*</span> <span> instances </span> </div>
<div class="field-input multiselect-item">
<input type="text" id="Instances" placeholder="Start typing here to see results.." readonly="true" required="true" onclick="openSelectableDropdown('#Instances_drop_down', '#Instances_drop_down_arrow')"
selectedValue="" />
<i id="Instances_drop_down_arrow" class="fas fa-angle-down dropdown-arrow" onclick="toggleSelectableDropdown('#Instances_drop_down', '#Instances_drop_down_arrow')"></i>
<div id="Instances_drop_down" class="autocomplete-dropdown selectable-dropdown">
<div class="dropdown-wrapper">
<j:forEach items="${jvar_arr}" var="jvar_element">
<div class="dropdown-item" onclick="selectMulti(this, '#Instances',
'#Instances_drop_down');" value="${jvar_element}">${jvar_element} <i class="fas fa-check"></i></div>

</j:forEach>

</div>
</div>
</div>
</div>
</section>
*************************************************************************************
Ui page Client script
function selectMulti(item) {
// Display the item in the multiselect input field
$j("#" + $j(item).attr("value")).toggleClass("selected-item");
// Add the active-item class on the currently clicked item
$j(item).toggleClass("active-item");
// Show the check icon on the currently clicked item
$j(item).find(".fa-check").toggleClass("active-item-icon");
setValueOfHiddenPurposeField();
}​
please find the attached screen shot
find_real_file.png
 
Thanks & kind regards,
Reddy481.
 
1 ACCEPTED SOLUTION

Hi,

I am able to achieve using this

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

	<g:evaluate jelly="true" object="true" var="jvar_arr">
		var arr = ['Volvo','Audi','Opel','Nissan'];
		arr;
	</g:evaluate>
	<select name="cars" id="cars" multiple="true">
		<j:forEach items="${jvar_arr}" var="jvar_element">
			<option value="${jvar_element}">${jvar_element}</option>
		</j:forEach>
	</select>
</j:jelly>

Output:

find_real_file.png

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

15 REPLIES 15

Hi,

I am able to achieve using this

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

	<g:evaluate jelly="true" object="true" var="jvar_arr">
		var arr = ['Volvo','Audi','Opel','Nissan'];
		arr;
	</g:evaluate>
	<select name="cars" id="cars" multiple="true">
		<j:forEach items="${jvar_arr}" var="jvar_element">
			<option value="${jvar_element}">${jvar_element}</option>
		</j:forEach>
	</select>
</j:jelly>

Output:

find_real_file.png

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

@Reddy481 

Hope you are doing good.

Did my reply answer your question?

If my response helped you please mark it correct to close the question so that it benefits future readers as well.

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

@Reddy481 

Hope you are doing good.

Did my reply answer your question?

If my response helped you please mark it correct to close the question so that it benefits future readers as well.

Regards
Ankur

 

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

@Reddy481 

Hope you are doing good.

Did my reply answer your question?

If my response helped you please mark it correct to close the question so that it benefits future readers as well.

Regards
Ankur

 

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Hi Ankur,

I am working on UI pages and UI actions. I created multi select box through UI pages so, I can select the multiple option in frontend but, in backend it is giving me the first value that I selected every time but, I need all the selected values and need to be stored in the field of incident table.