View Full Version : <select> <option> ... works in IE6... does not work in firefox

01-12-2007, 10:19 PM
Hi All,

First of all, great forum. I have been using the search function for the past few days, and have learnt a lot from the excellent responses.

As much as I dont want to start another ... "doesnt work in firefox, but works in IE6 thread"... i think i have to...

anyway here is the problem....

I am updating a few text fields based on the option that user will select.
This update takes the values name11, address1, address2 (see fields in red ... in code below)
... etc and puts it into text fields.

This works perfectly in IE6.
But in firefox, the text fields are filled with "undefined" =/

<select id="OptSiteNO" onChange="javascript:setFromSiteValues();DirtyFlag();" <c:if test="${sessionScope.ReadOnly eq 'true'}"> class="readOnlyTextbox" readonly="readonly" disabled="disabled"</c:if>>
<option value="" selected>Select One</option>

<c:forEach items="${fromSiteList}" var="fromSite">
<option value="<c:out value="${fromSite.site}" />"
<c:if test='${selectedFromSite.site eq fromSite.site }'> selected </c:if>
address1="<c:out value="${fromSite.addressLine1}"/>"
address2="<c:out value="${fromSite.addressLine2}"/>"
city="<c:out value="${fromSite.city}"/>"
zip="<c:out value="${fromSite.zipCode}"/>"
state="<c:out value="${fromSite.state}"/>"
countryCode="<c:out value="${fromSite.countryCode}"/>" maxLength="10">
<c:out value="${fromSite.site}" />

<option value="Add New Address">Add Address</option>

javascript function that takes the values and puts them in the text field...

function setFromSiteValues()
fromSiteSelectedIndex = document.getElementById('OptSiteNO').selectedIndex;
fromSiteSelectedOption = document.getElementById('OptSiteNO').options[fromSiteSelectedIndex];

document.new_shipment.txtSiteNO.value = fromSiteSelectedOption.value;
document.getElementById('txtFromName').value = fromSiteSelectedOption.name11;
document.new_shipment.txtFromAddress1.value = fromSiteSelectedOption.address1;
document.new_shipment.txtFromAddress2.value = fromSiteSelectedOption.address2;
document.new_shipment.txtFromCity.value = fromSiteSelectedOption.city;
document.new_shipment.txtFromZip.value = fromSiteSelectedOption.zip;
document.new_shipment.txtFromState.value = fromSiteSelectedOption.state;
document.new_shipment.txtFromCountry.value = fromSiteSelectedOption.countryCode;

NOTE: from what I gathered from research (using the search button on this forum... :p) the problem is mainly because of the way i have the option declared (something is not the way firefox wants it to be)

please let me know if you need any more details.. (this is my first time seeking help on the net. so, sorry if i missed any details)

thanks in advance

01-13-2007, 01:30 AM
Do you happen to have a link to a test version of it that works in IE and not FF? I've never used JSTL plus don't have access to the information it uses to create the html page.

That said, you could try changing




and see if it makes a difference.


01-14-2007, 01:12 PM

I don't know what server language that is, but...

The option tag, other than "selected", has just one attribute: value. You will need to string together the various data items, along with a "spacer", as a single "value" for that option. I used "|", as a spacer, below.

name11="nick" + "|" + address1="<c:out value="${fromSite.addressLine1}"/>" + "|" + address2="<c:out value="${fromSite.addressLine2}"/>" +"|" +city="<c:out value="${fromSite.city}"/>" ... etc...

Then you pass the value to your function, using "this.value", the function then "splits" the various items, at the spacer:


function setFromSiteValues(nVal)
var itemVal = nVal.split("|");
document.new_shipment.txtSiteNO.value = itemVal[0];
document.getElementById('txtFromName').value = itemVal[1];
document.new_shipment.txtFromAddress1.value = itemVal[2]
... etc...