Javascript with IE 7

K

KA Kueh

Dear all,

I am having problems with "document.getElementsById " in IE7 where it will
throw an error. The same piece of code works perfectly in IE 6 and Firefox
2. Sample code as shown below. What can be done? Thanks.

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="TestForm1.aspx.cs"
Inherits="TestForm1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">

<title>Untitled Page</title>

<script type="text/javascript">

function test()

{


document.getElementsById('RadioButtonXX').disabled=false;


}

</script>

</head>

<body>

<form id="form1" runat="server">

<asp:ScriptManager ID="ScriptManager1" runat="server" >

</asp:ScriptManager>

<div>

<asp:button ID="btnDelete" runat="server" onClientClick="return confirm('Are
you sure you want to delete this mailbox?')" Text="Delete" />

<asp:RadioButtonList ID="RadioButtonList1" runat="server" >

<asp:ListItem>Apple</asp:ListItem>

<asp:ListItem>Orange</asp:ListItem>

</asp:RadioButtonList>

<asp:CustomValidator ID="CustomValidator1" runat="server"
ClientValidationFunction="test"

ControlToValidate="RadioButtonList1">

</asp:CustomValidator>

<asp:DropDownList ID="DropDownList1" runat="server">

<asp:ListItem Text="One" Value="1"></asp:ListItem>

<asp:ListItem Text="Two" Value="2"></asp:ListItem>

</asp:DropDownList>

<asp:RadioButtonList ID="RadioButtonXX" Enabled="true" runat="server" >

<asp:ListItem>Car</asp:ListItem>

<asp:ListItem>Lorry</asp:ListItem>

</asp:RadioButtonList >

</div>


</form>


</body>

</html>
 
M

Mark Rae [MVP]

I am having problems with "document.getElementsById " in IE7 where it will
throw an error.

You know, there is very little point in posting to a technical newsgroup
saying that something will throw an error...

....if you don't actually say what that error is...
 
K

KA Kueh

Hi Mark,

Ok. I am getting the following error, which is cause by the
document.getElementsById syntax.

Microsoft JScript runtime error: Object doesn't support this property or
method


Regards,
 
M

Mark Rae [MVP]

Ok. I am getting the following error, which is cause by the
document.getElementsById syntax.

Microsoft JScript runtime error: Object doesn't support this property or
method

Well there you go - document.getElementsById doesn't exist...

You can use:
document.getElementById(...)
document.getElementsByName(...)
document.getElementsByTagName(...)
document.getElementsByTagNameNS(...)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,968
Messages
2,570,150
Members
46,697
Latest member
AugustNabo

Latest Threads

Top