radiobuttonlist and javascript

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • sramruttun

    #1

    radiobuttonlist and javascript

    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.Clien tId &
    "');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:RadioButto nList 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:RadioButton List>
    </TD>
    </TR>


    In the script section I have:
    function ShowPeriod(w)
    {
    document.all(w) .visible=true;
    //document.getEle mentById("RDLPe riod").style.vi sibility=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 ?


  • sramruttun

    #2
    Re: radiobuttonlist and javascript

    thanks marina
    I realise the point. What do u suggest?

    "Marina" <zlatkinam@nosp am.hotmail.com> wrote in message
    news:#AtSIv5TDH A.3144@tk2msftn gp13.phx.gbl...[color=blue]
    > Setting the visible property of a server side object to False, means that
    > the HTML for it doesn't even get streamed down to the client. This is very
    > different from setting the "display:no ne" in the style of the object.
    >
    > The problem is, the HTML for your radiobuttonlist never made it to the
    > client. This will be easy to check by chosing View -> Source from the menu
    > in IE.
    >
    > "sramruttun " <sramruttun@yah oo.com> wrote in message
    > news:%23pPjrN4T DHA.556@TK2MSFT NGP12.phx.gbl.. .[color=green]
    > > hi
    > > I have a checkbox and a radiobuttonlist (the radiobuttonlist contains 2
    > > items) in my form. The radiobuttonlist has its visible property set to[/color]
    > false[color=green]
    > > at design time. At run time, when the checkbox is checked, then I want[/color][/color]
    the[color=blue][color=green]
    > > radiobuttonlist to appear. I want to use javascript.
    > >
    > > On Form_Load I've done:
    > > chkM.Attributes .Add("onclick", "ShowPeriod ('" & RDLPeriod.Clien tId &
    > > "');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:RadioButto nList 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:RadioButton List>
    > > </TD>
    > > </TR>
    > >
    > >
    > > In the script section I have:
    > > function ShowPeriod(w)
    > > {
    > > document.all(w) .visible=true;
    > > //document.getEle mentById("RDLPe riod").style.vi sibility=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 ?
    > >
    > >[/color]
    >
    >[/color]


    Comment

    • S. Justin Gengo

      #3
      Re: radiobuttonlist and javascript

      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("onclic k")

      I hope this helps.

      --
      S. Justin Gengo, MCP
      Web Developer

      Free code library at:
      www.aboutfortunate.com

      "Out of chaos comes order."
      Nietzche
      "sramruttun " <sramruttun@yah oo.com> wrote in message
      news:uMU1D9AUDH A.2520@tk2msftn gp13.phx.gbl...[color=blue]
      > thanks marina
      > I realise the point. What do u suggest?
      >
      > "Marina" <zlatkinam@nosp am.hotmail.com> wrote in message
      > news:#AtSIv5TDH A.3144@tk2msftn gp13.phx.gbl...[color=green]
      > > Setting the visible property of a server side object to False, means[/color][/color]
      that[color=blue][color=green]
      > > the HTML for it doesn't even get streamed down to the client. This is[/color][/color]
      very[color=blue][color=green]
      > > different from setting the "display:no ne" in the style of the object.
      > >
      > > The problem is, the HTML for your radiobuttonlist never made it to the
      > > client. This will be easy to check by chosing View -> Source from the[/color][/color]
      menu[color=blue][color=green]
      > > in IE.
      > >
      > > "sramruttun " <sramruttun@yah oo.com> wrote in message
      > > news:%23pPjrN4T DHA.556@TK2MSFT NGP12.phx.gbl.. .[color=darkred]
      > > > hi
      > > > I have a checkbox and a radiobuttonlist (the radiobuttonlist contains[/color][/color][/color]
      2[color=blue][color=green][color=darkred]
      > > > items) in my form. The radiobuttonlist has its visible property set to[/color]
      > > false[color=darkred]
      > > > at design time. At run time, when the checkbox is checked, then I want[/color][/color]
      > the[color=green][color=darkred]
      > > > radiobuttonlist to appear. I want to use javascript.
      > > >
      > > > On Form_Load I've done:
      > > > chkM.Attributes .Add("onclick", "ShowPeriod ('" & RDLPeriod.Clien tId &
      > > > "');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:RadioButto nList 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:RadioButton List>
      > > > </TD>
      > > > </TR>
      > > >
      > > >
      > > > In the script section I have:
      > > > function ShowPeriod(w)
      > > > {
      > > > document.all(w) .visible=true;
      > > > //document.getEle mentById("RDLPe riod").style.vi sibility=true;
      > > > }
      > > >
      > > > Upon execution, when I check the checkbox, the code breaks in the[/color][/color][/color]
      script[color=blue][color=green][color=darkred]
      > > > section and tells that :
      > > > 'document.all(. ..)' is null or not an object
      > > >
      > > > Where is problem guys ?
      > > >
      > > >[/color]
      > >
      > >[/color]
      >
      >[/color]


      Comment

      Working...