Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. TextBox appear depended on checkbox

TextBox appear depended on checkbox

Scheduled Pinned Locked Moved ASP.NET
javascriptsysadmintoolstutorialquestion
7 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    MichaeltCheong
    wrote on last edited by
    #1

    <script language="javascript" type="text/javascript">

           function forRentClicked(sender) {
    
                   var tb1 = document.getElementById('<%= TextBox4.ClientID %>');
                   tb1.style.display = sender.checked ? 'inline' : 'none';
           }
    
        </script>
    

    _____________________________________________________________

    <asp:CheckBox ID="CheckBox1" runat="server"
    Text=" XS" onClick="forRentClicked(this)" Checked="True" />

    <asp:TextBox ID="TextBox4" runat="server" Height="19px" Width="80%" CssClass="123"
    style="display:block;" ></asp:TextBox >

    how to set the default checkbox uncheck and the javascript can function ~ i want to create 5 check box while i'm click the text box appear~ thx

    M J L 3 Replies Last reply
    0
    • M MichaeltCheong

      <script language="javascript" type="text/javascript">

             function forRentClicked(sender) {
      
                     var tb1 = document.getElementById('<%= TextBox4.ClientID %>');
                     tb1.style.display = sender.checked ? 'inline' : 'none';
             }
      
          </script>
      

      _____________________________________________________________

      <asp:CheckBox ID="CheckBox1" runat="server"
      Text=" XS" onClick="forRentClicked(this)" Checked="True" />

      <asp:TextBox ID="TextBox4" runat="server" Height="19px" Width="80%" CssClass="123"
      style="display:block;" ></asp:TextBox >

      how to set the default checkbox uncheck and the javascript can function ~ i want to create 5 check box while i'm click the text box appear~ thx

      M Offline
      M Offline
      Martin OHV
      wrote on last edited by
      #2

      Hi Michael, sorry but i think i dont understand your question... the Check-Status of an ASP Checkbox can be assigned within the ASP Tag (Checked="True|False") the Actual Script seems to be hiding showing the Textbox4 independend of other textboxes or checkboxes... So maybe you can give us more details... Martin

      M 1 Reply Last reply
      0
      • M MichaeltCheong

        <script language="javascript" type="text/javascript">

               function forRentClicked(sender) {
        
                       var tb1 = document.getElementById('<%= TextBox4.ClientID %>');
                       tb1.style.display = sender.checked ? 'inline' : 'none';
               }
        
            </script>
        

        _____________________________________________________________

        <asp:CheckBox ID="CheckBox1" runat="server"
        Text=" XS" onClick="forRentClicked(this)" Checked="True" />

        <asp:TextBox ID="TextBox4" runat="server" Height="19px" Width="80%" CssClass="123"
        style="display:block;" ></asp:TextBox >

        how to set the default checkbox uncheck and the javascript can function ~ i want to create 5 check box while i'm click the text box appear~ thx

        J Offline
        J Offline
        jkirkerx
        wrote on last edited by
        #3

        I think you of just search for each component and just pieced it together yourself.

        function forRentClicked(sender) {

        var checked = document.getElementById('CheckBox1').checked;
        var textbox\_4 = document.getElementById('<%= TextBox4.ClientID %>');
        
        if (checked == true) {
          textbox\_4.style.display = "block";
        }
        else {
          textbox\_4.style.display = "none";
        }
        

        }

        M 1 Reply Last reply
        0
        • M MichaeltCheong

          <script language="javascript" type="text/javascript">

                 function forRentClicked(sender) {
          
                         var tb1 = document.getElementById('<%= TextBox4.ClientID %>');
                         tb1.style.display = sender.checked ? 'inline' : 'none';
                 }
          
              </script>
          

          _____________________________________________________________

          <asp:CheckBox ID="CheckBox1" runat="server"
          Text=" XS" onClick="forRentClicked(this)" Checked="True" />

          <asp:TextBox ID="TextBox4" runat="server" Height="19px" Width="80%" CssClass="123"
          style="display:block;" ></asp:TextBox >

          how to set the default checkbox uncheck and the javascript can function ~ i want to create 5 check box while i'm click the text box appear~ thx

          L Offline
          L Offline
          liuguozhu2015
          wrote on last edited by
          #4

          Hello Michael5119,

          has not "onclick"event,you can use

          <input id="Checkbox1" type="checkbox" onclick="forRentClicked(this)"/>

          to replace it.

          M 1 Reply Last reply
          0
          • M Martin OHV

            Hi Michael, sorry but i think i dont understand your question... the Check-Status of an ASP Checkbox can be assigned within the ASP Tag (Checked="True|False") the Actual Script seems to be hiding showing the Textbox4 independend of other textboxes or checkboxes... So maybe you can give us more details... Martin

            M Offline
            M Offline
            MichaeltCheong
            wrote on last edited by
            #5

            thx :)

            1 Reply Last reply
            0
            • L liuguozhu2015

              Hello Michael5119,

              has not "onclick"event,you can use

              <input id="Checkbox1" type="checkbox" onclick="forRentClicked(this)"/>

              to replace it.

              M Offline
              M Offline
              MichaeltCheong
              wrote on last edited by
              #6

              thx ~ :)

              1 Reply Last reply
              0
              • J jkirkerx

                I think you of just search for each component and just pieced it together yourself.

                function forRentClicked(sender) {

                var checked = document.getElementById('CheckBox1').checked;
                var textbox\_4 = document.getElementById('<%= TextBox4.ClientID %>');
                
                if (checked == true) {
                  textbox\_4.style.display = "block";
                }
                else {
                  textbox\_4.style.display = "none";
                }
                

                }

                M Offline
                M Offline
                MichaeltCheong
                wrote on last edited by
                #7

                thx ~ :)

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups