SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Evangelist
    Join Date
    May 2006
    Posts
    457
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    show / hide a textbox on checkbox check

    Hello all, im trying to hide/show a checkbox on checkbox change:

    Code:
    <%@ Page Language="C#" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            DiscretionaryCheckbox.Checked = true;
        }
    </script>
    
    <script type="text/javascript" language="javascript"> 
    function Show(id)
    {
    el = document.getElementById(id); 
    el.style.display = "block"; 
    } 
    function Hide(id)
    {
    el = document.getElementById(id); 
    el.style.display = "none"; 
    } 
    </script>
    
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title>Untitled Page</title>
    </head>
    <body>
    <form id="form1" runat="server">
        <table style="width: 616px; height: 106px">
            <tr>
                <td style="font-size: 9pt; width: 269px; font-family: Arial">
                    <asp:RadioButton ID="DiscretionaryCheckbox" runat="server" CssClass="Checkbox" GroupName="1"
                        TabIndex="9" Text="Discretionary" onclientclick="Hide('Other');"/>
                    <asp:RadioButton ID="OtherCheckbox" runat="server" CssClass="Checkbox" GroupName="1"
                        TabIndex="10" Text="Other" onclientclick="Show('Other');""/></td>
            </tr>
            <tr>
                <td style="font-size: 9pt; width: 269px; font-family: Arial">
                    <asp:TextBox ID="Other" runat="server" CssClass="Textbox" TabIndex="11" style="display:none"></asp:TextBox></td>
            </tr>
        </table>
    </form>
    </body>
    </html>
    Any ideas why its not working?

  2. #2
    SitePoint Enthusiast
    Join Date
    Jan 2006
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try posting in the ASP forum.

    Or-
    work up a file with only HTML an Javascript.
    Get the checkbox functionality working then make the changes in your ASP file.


    -Bill


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •