radiobuttonlist and javascript

S

sramruttun

hi
I have a checkbox and a radiobuttonlist (the radiobuttonlist contains 2
items) in my form. The radiobuttonlist has its visible property set to false
at design time. At run time, when the checkbox is checked, then I want the
radiobuttonlist to appear. I want to use javascript.

On Form_Load I've done:
chkM.Attributes.Add("onclick", "ShowPeriod('" & RDLPeriod.ClientId &
"');return false;")


The HTML Source:

<TR>
<TD>
<asp:Label id="Label8" runat="server">Monthly</asp:Label>&nbsp;
<asp:CheckBox id="chkM" runat="server" Width="81px"></asp:CheckBox>
</TD>
<TD colSpan="3">
<asp:Label id="Label9" runat="server">Period</asp:Label>&nbsp;
<asp:RadioButtonList id="RDLPeriod" runat="server"
RepeatDirection="Horizontal" Visible="False">
<asp:ListItem Value="All">All</asp:ListItem>
<asp:ListItem Value="Current Year">Current Year</asp:ListItem>
</asp:RadioButtonList>
</TD>
</TR>


In the script section I have:
function ShowPeriod(w)
{
document.all(w).visible=true;
//document.getElementById("RDLPeriod").style.visibility=true;
}

Upon execution, when I check the checkbox, the code breaks in the script
section and tells that :
'document.all(...)' is null or not an object

Where is problem guys ?
 
S

S. Justin Gengo

Sam,

Attach the javascript at the same time you set the list to visible, and
remove it if the list's visiblity is reset to false.

chkM.Attributes.Remove("onclick")

I hope this helps.

--
S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
 

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

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top