Liferay 7.2 - How to get the aui:select index?

Fabio Carvalho, modified 6 Years ago. Junior Member Posts: 81 Join Date: 6/25/19 Recent Posts
Hi,

I have the following view.jsp:
<%@ include file="/init.jsp" %>

<%@ page import="java.util.List" %>
<%@ page import="packagename.servicebuilder.service.ProductLocalServiceUtil" %>
<%@ page import="packagename.servicebuilder.model.Product" %>

&lt;% List<product> products = ProductLocalServiceUtil.getProducts(0, ProductLocalServiceUtil.getProductsCount()); %&gt;

<aui:select label="Delete Product" name="productId">&nbsp;
    &lt;% for (Product product : products) { %&gt;&nbsp; &nbsp; 
&nbsp;       <aui:option value="<%= product.getProductId() %>">&lt;%= product.getProductName() %&gt;</aui:option>
    &lt;% } %&gt;
</aui:select>
<aui:input label="Product Description" value="this should change" type="text" readonly="true" /></product>

My goal is to change the Product Description when we select something from the aui:select. I was thinking that maybe, if I can get the selected index, I could change the value of the label by using something like this:

<aui:input label="Product Description" value="<%=&nbsp;products.get(aui:select:index).getProductDescription()&nbsp; %>" type="text" readonly="true" />

How can I get the select index of my aui:select? I think that I also need the changesContext param to update the values?
thumbnail
Mohammed Yasin, modified 6 Years ago. Liferay Master Posts: 593 Join Date: 8/8/14 Recent Posts
Hi, May be you can have hidden input tag for description and onChange() event show which this on.
<aui:input name="descrption<%=product.getProductId() %>" value="<%=product.getDescription() %>"  type="hidden" />
function updateDesc() {
&nbsp;&nbsp; &nbsp;//Show description input tag
&nbsp;&nbsp; &nbsp;
}