Hide/Show depending on checkbox

3 posts, 1 answers
  1. Elliott
    Elliott avatar
    392 posts
    Member since:
    May 2010

    Posted 19 Feb 2013 Link to this post

    I'd like to implement the following, on the client if at all possible

    a user control has a checkbox and a dropdown
    it loads with the checkbox unchecked and the dropdown hidden
    if the user checks the checkbox the dropdown becomes visible
    if the user unchecks the checkbox the dropdown becomes hidden

    sounds so simple, right?
    any assistance is appreciated
  2. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 19 Feb 2013 Link to this post

    Hi Marianne,

    Try the following markup and JS to achieve your scenario
    aspx:
    <asp:CheckBox ID="CheckBox1" runat="server" onclick="OnCheckedChanged(this)" />
    <telerik:RadComboBox ID="RadComboBox1" runat="server">
        <Items>
            <telerik:RadComboBoxItem Text="001" />
            <telerik:RadComboBoxItem Text="002" />
            <telerik:RadComboBoxItem Text="003" />
        </Items>
    </telerik:RadComboBox>
    JS:
    <script type="text/javascript">
    function OnCheckedChanged(sender)
    {
     
    if (sender.checked == true)
        {
            var combo = document.getElementById('<%= RadComboBox1.ClientID %>').disabled = true;
        }
    else
        {
            var combo = document.getElementById('<%= RadComboBox1.ClientID %>').disabled = false;
        }
     
    }
    </script>

    Thanks,
    Princy
  3. Elliott
    Elliott avatar
    392 posts
    Member since:
    May 2010

    Posted 20 Feb 2013 Link to this post

    thanks!

    I was getting bollixed up because onchange doesn't get raised in IE8
Back to Top