Link to home
Start Free TrialLog in
Avatar of huzefaq
huzefaq

asked on

how to call javascript inside html <select> tags

I have a select tag which populates all the countries. What I need is that when United states is selected it executes a javascript which basically populates the states drop down.

I tried putting the code to call teh javascript inside an if statement which is inside of select tags but somehow it puts teh javascript code as one of the values in dropdown. Would you guys know if I am doing something wrong. Also if this is not possible is there a way I can check outside the select tags if United states is selected, if it is than execute the javascript code.

Any help weill be greatly appreciated

----------------

<select class="logon select" id="<c:out value="WC_AddressEntryForm_FormInput_${prefix}country_1"/>" name="<c:out value="${prefix}country"/>" onchange="javascript:loadStatesUI(this.options[this.selectedIndex].value,<c:out value="${formName}"/>, '<c:out value="${prefix}"/>')" >
                  <c:forEach var="country" items="${countryBean.countries}">
                   <c:out value"${country.code}" />
                        <option value="<c:out value="${country.code}"/>"
                              <c:if test="${country.code eq USACountry}">
                                    selected="selected"
                                    <Script>
                                    loadStatesFirstUI(this.options[this.selectedIndex].value,<c:out value="${formName}"/>, '<c:out value="${prefix}"/>')
                                    </Script>
                              </c:if>
                              <c:if test="${country.code eq paramSource.country || country.displayName eq paramSource.country}">
                                    selected="selected"
                              </c:if>
                        ><c:out value="${country.displayName}"/></option>
                  </c:forEach>
            </select>
ASKER CERTIFIED SOLUTION
Avatar of Isisagate
Isisagate

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial