dkaur76
November 17, 2010, 4:16am
1
I amt trying to get the selectedIndex on my dropdown list, but I am getting ‘object required’ error. Please review my code and suggest correction:
<script type=“text/javascript”>
function EnablePanel() {
index = this.document.getElementById(‘adv_client’).selectedIndex;
if (index > 0) this.document.getElementById(‘panel3’).Enabled = true;
}
</script>
Thank You.
system
November 17, 2010, 4:18am
2
try
index = document.getElementById('adv_client').selectedIndex;
and make sure the id of the <select> is ‘adv_client’
dkaur76
November 17, 2010, 1:44pm
3
I still get the error: Microsoft JScript runtime error: Object required
<script type="text/javascript">
function EnablePanel3() {
index = document.getElementById('adv_client').selectedIndex;
if (index > 0) document.getElementById('panel3').Enabled = true;
}
</script>
<asp:Panel ID="panel2" runat="server" GroupingText="CLIENT" EnableViewState="true" >
<tr>
<td class="cls">CLIENT</td><td><asp:DropDownList ID="adv_client" runat="server" OnInit="adv_client_Init" ></asp:DropDownList></td>
</tr>
</asp:Panel>
</table>
<asp:Panel ID="panel3" runat="server" GroupingText="Doctors" EnableViewState="true" >
<table>
<tr>
<td class="cls">Facility1</td><td><asp:DropDownList ID="adv_ord_ddl" runat="server"
onselectedindexchanged="adv_ord_ddl_SelectedIndexChanged"
oninit="adv_ord_ddl_Init" ></asp:DropDownList>
</td>
</tr>
<tr>
<td class="cls">Facility2</td><td><asp:DropDownList ID="adv_treat_ddl" runat="server" OnSelectedIndexChanged="adv_treat_ddl_SelectedIndexChanged"
OnInit="adv_treat_ddl_Init"></asp:DropDownList></td>
</tr>
</asp:Panel>
</table>
A test page that demonstrates the problem, will enable us to apply some debugging techniques to find and fix the problem.
If you cannot provide a test page, posting the rendered HTML code will be more helpful than the ASP source code.