I am trying to use the <html:select> tag in my jsp page but am getting the
following javascript error,
Microsoft JScript runtime error: Object expected.
In my jsp page I have:
<table align="left" class="tableGold">
<tr>
<th align="left" bgcolor="#EEE8AA"><font size="-1"
color="#ff0000">*</font><bean:message key="table.head.category"/></th>
</tr>
<tr>
<td align="center" valign="middle" >
<div>
<div style="{float: left;}" >
<html:select styleId="category" property="devicecategoryid"
onchange="selectDevOrStent()">
<html:option value=""><bean:message
key="select.list.device.category"/></html:option>
<html:options collection="DeviceCategory" property="id"
labelProperty="description"/>
</html:select>
</div>
<div id="otherdev" style="{float: left; display: none; font-family: Arial,
Helvetica, sans-serif; font-size: xx-small; vertical-align: middle;
padding-left: 50px; line-height: 1.2em}">
<html:text property="other" size="35" maxlength="60" onfocus="clearOther()"
value = "Enter Device Description" />
</div>
</div>
</td>
</tr>
</table>
Here is the javascript funtion that is called when a onchange event is detected:
function selectDevOrStent(){
alert("In SelectDevOrStent");
var category = id("category").options[id("category").selectedIndex].value;
var categoryText = id("category").options[id("category").selectedIndex].text;
//alert("categoryText = " + categoryText);
if(categoryText == 'Stents'){
//alert("Stent selected");
id("stent").style.display = "block";
id("dev").style.display = "none";
id("otherdev").style.display = "none";
getSelectList("category", "StentManufacturerSelect.do", stentmanufcallback);
}else if(categoryText == 'Joint Replacement'){
//alert("Joint Replacement selected");
document.DeviceInputForm.devicetypeid.disabled='true';
document.DeviceInputForm.manufacturer.disabled='true';
document.DeviceInputForm.modelnumber.disabled='true';
getSelectList("category", "DeviceLocationSelect.do?devicecategoryid=" +
escape(id("category").value), locationcallback);
id("dev").style.display = "block";
id("stent").style.display = "none";
id("otherdev").style.display = "none";
}else if(categoryText == 'Other'){
//alert("Other selected");
id("otherdev").style.display = "block";
id("stent").style.display = "none";
id("dev").style.display = "none";
}else{
//alert("Stent not selected");
id("stent").style.display = "none";
id("dev").style.display = "block";
id("otherdev").style.display = "none";
getSelectList("category", "DeviceTypeSelect.do?devicecategoryid=" +
escape(id("category").value), devicecallback);
}
}
Everything is fine, I can see the select box and all the options are there but
when I trigger a onchange event I get the error. Can anyone see what I am doing
wrong?
Thanks.