cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

How to listen to onchange event in formSelectBox?

Former Member
0 Kudos
779

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?

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Agustín,

Please ensure that you are modifying correct tag file (WEB-INF\tags\responsive\formSelectBox.tag).

Thanks!!

Former Member
0 Kudos

I am but the form:select from Spring is not accepting the onchange event, though as far as I can remember, you can use the event attributes on them

Former Member
0 Kudos

It has been defined in AbstractHtmlInputElementTag class of spring-webmvc-x.jar, so it should work. What exact error you are getting?

Ask a Question