Hi,
I added checkboxes to my page, and I want to change their status on client side using javascript.
JavaScript:
< script language="javascript">
function CheckTwo(chkBox)
{
if(chkBox.checked)
{ document.getElementById( "Two").checked=true; }
else
{ document.getElementById( "Two").checked=false; }
}
function CheckAll(CheckAllBox)
{
if(CheckAllBox.checked)
{ document.getElementById( "one").checked=true;
document.getElementById("two").checked=true;
....
}
Behind Code:
protected void Page_Load(object sender, EventArgs e)
{
One.Attributes.Add( "OnClick", CheckTwo(this)");
Three.Attributes.Add( "OnClick", CheckAll(this)");
...
}
ASP/HTML:
<td>
<asp:CheckBox id="One" Text="One" runat="server" OnClick=CheckTwo(this)" />
</td>
<td>
<asp:CheckBox id="Two" Text="Two" runat="server" />
</td>
<td>
<asp:CheckBox ID="Three" Text="Three" runat="server" OnClick=CheckAll(this)" />
</td>
Can you help me of what I am doing wrong, as I keep getting javascript error "document.getElementById is null or not an object"
Thank you,
Yaron.
Visual Studio Express Editions15
|