Skip to Content
0
Apr 26, 2018 at 03:24 AM

How to listen to onchange event in formSelectBox?

479 Views

I'm using Hybris 6.2, I need to listen to the onchange event for the formSelectBox element.

I tried to modify it like this:

         <div class="control">
             <form:select id="${idKey}" path="${path}" cssClass="${selectCSSClass}" tabindex="${tabindex}" disabled="${disabled}" onchange="${onchange}">
                 <c:if test="${skipBlank == null || skipBlank == false}">
                     <option value="" disabled="disabled" ${empty selectedValue ? 'selected="selected"' : ''}>
                         <spring:theme code='${skipBlankMessageKey}'/>
                     </option>
                 </c:if>
                 <form:options items="${items}" itemValue="${not empty itemValue ? itemValue :'code'}" itemLabel="${not empty itemLabel ? itemLabel :'name'}"/>
             </form:select>
         </div>

And used it like this:

 <formElement:formSelectBox idKey="address.district" labelKey="address.district2" path="district" selectCSSClass="form-control"  mandatory="true" skipBlank="false" skipBlankMessageKey="address.district" items="${districts}" tabindex="7"
 onchange="changedDistrict()" />

But when I try to access my page an error is displayed saying the attribute onchange is not valid.

Why is it not accepting the onchange attribute?