|
-
Oct 20th, 2005, 04:20 PM
#1
Thread Starter
Fanatic Member
[RESOLVED] firing javascript on OnCheckChanged radiobutton event
I have some javascript that I'm trying to fire off when the checked status of a radiobutton is changed. its suppose to uncheck any checkboxes that are checked on my page. the checkboxes are named CheckBox1, CheckBox2, etc. Here is my javascript
Code:
<script type = "text/javascript">
function uncheckAll()
{
for (var j = 1; j <= 14; j++)
{
box = eval("document.Form1.CheckBox" + j);
if (box.checked == true) box.checked = false;
}
}
</script>
and here is my code in my html:
Code:
<asp:RadioButton id="OptionButton3" OnCheckedChanged="uncheckAll()" runat="server" Text="CONCENTRIC OR COMPRESSED" GroupName="CableType"></asp:RadioButton>
But when I load the page i get this error:
Compiler Error Message: BC30456: 'uncheckAll' is not a member of 'ASP._500_10_aspx'.
I'm coding in VS.net. Why can't it recognize it?
Thank you!
Last edited by drpcken; Oct 21st, 2005 at 05:54 PM.
-
Oct 20th, 2005, 04:28 PM
#2
Re: firing javascript on OnCheckChanged radiobutton event
You cannot execute client side script by using a tag within a server side object.
Therefore, make the radio button like this:
<asp:RadioButton id="OptionButton3" runat="server" Text="CONCENTRIC OR COMPRESSED" GroupName="CableType"></asp:RadioButton>
Then, in the Page_Load event, do the following Response.Write:
Response.Write("<sc" + "ript lang=\"javascript\" for=\"" + OptionButton2.clientID + "\" event=\"OnCheckChanged\">uncheckAll()</sc" + "ript>");
Need to re-register ASP.NET?
C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i
(Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)
-
Oct 20th, 2005, 04:34 PM
#3
Thread Starter
Fanatic Member
Re: firing javascript on OnCheckChanged radiobutton event
Well I changed the OnCheckChanged event to OnClick (even though VS.NET doesn't like it and underlines it) and it worked perfectly.
Which is better?
-
Oct 20th, 2005, 04:37 PM
#4
Re: firing javascript on OnCheckChanged radiobutton event
OnClick working for you, provided it continues, is a fluke.
If it is, indeed, working, then ignore the underline and keep going.
For future reference, make sure the code above is easily accessable for you.
Need to re-register ASP.NET?
C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i
(Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)
-
Oct 20th, 2005, 04:39 PM
#5
Thread Starter
Fanatic Member
Re: firing javascript on OnCheckChanged radiobutton event
Thanks again! I'll be back soon with more questions I'm sure.
Thanks for eveything!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|