Hiding a textbox while checking a check box

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • hellboss
    New Member
    • Jun 2007
    • 50

    Hiding a textbox while checking a check box

    Hi everyone ! my problem is , i tried to disable a textbox control by writing this code "textbox1.visib le =false" inside the checkbox checked event ! but the event didnt fire ! Kindly get me some alternative idea! or plz tell me can i use any other control to do this operation !
  • jhardman
    Recognized Expert Specialist
    • Jan 2007
    • 3405

    #2
    onclick="this.f orm.myTextBox1. style.visibilit y='hidden'"

    This isn't really an asp question. I'll send this over to the javascript/ajax forum to see if any of those guys have any comments.

    Jared

    Comment

    • acoder
      Recognized Expert MVP
      • Nov 2006
      • 16032

      #3
      Do you want to hide or disable the text box?

      You have already been shown how to hide. visibility should be set to "hidden", not 'false'.

      To disable instead of hide, use the disabled property and set it to true.

      Comment

      • hellboss
        New Member
        • Jun 2007
        • 50

        #4
        Originally posted by acoder
        Do you want to hide or disable the text box?

        You have already been shown how to hide. visibility should be set to "hidden", not 'false'.

        To disable instead of hide, use the disabled property and set it to true.
        Dear Sir/mam !

        The solution for which i needed is, i need to hide a dropdown list by overlapping the textbox over it while checking the check box(in asp.net vs 05), but the check box's check event doesnt responds or fires when i check the box ! watz the solution for this ! Kindly help me !

        Comment

        • KishoreM
          New Member
          • Jun 2007
          • 12

          #5
          Originally posted by hellboss
          Hi everyone ! my problem is , i tried to disable a textbox control by writing this code "textbox1.visib le =false" inside the checkbox checked event ! but the event didnt fire ! Kindly get me some alternative idea! or plz tell me can i use any other control to do this operation !
          [HTML]
          <html>
          <script>
          function fun1()
          {

          if(document.for ms[0].testcheck.chec ked == true)
          {
          document.forms[0].username.style .visibility='hi dden';
          }
          else
          {
          document.forms[0].username.style .visibility='vi sible';
          }
          }
          </script>
          <body>
          <form>
          checkbox testing example.
          <input type="text" name="username" value="Test">
          <input type="checkbox" name="testcheck " onclick="fun1() ">
          </form>
          </body>

          </html>
          [/HTML]

          Comment

          Working...