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:loadS tatesUI(th is.options [this.sele ctedIndex] .value,<c: out value="${formName}"/>, '<c:out value="${prefix}"/>')" >
<c:forEach var="country" items="${countryBean.count ries}">
<c:out value"${country.code}" />
<option value="<c:out value="${country.code}"/>"
<c:if test="${country.code eq USACountry}">
selected="selected"
<Script>
loadStatesFirstUI(this.opt ions[this. selectedIn dex].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.displayNa me}"/></op tion>
</c:forEach>
</select>
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
<c:forEach var="country" items="${countryBean.count
<c:out value"${country.code}" />
<option value="<c:out value="${country.code}"/>"
<c:if test="${country.code eq USACountry}">
selected="selected"
<Script>
loadStatesFirstUI(this.opt
</Script>
</c:if>
<c:if test="${country.code eq paramSource.country || country.displayName eq paramSource.country}">
selected="selected"
</c:if>
><c:out value="${country.displayNa
</c:forEach>
</select>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.