disabling text boxes

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • harig
    New Member
    • Jul 2007
    • 10

    #1

    disabling text boxes

    hi all,

    i've five text boxes followed by a check box ..... when i check the checkbox it shud disable all the text boxes.... when i uncheck it the vice-versa shud happen..

    how do i do it???? help me out of dis



    Thanx
  • gits
    Recognized Expert Moderator Expert
    • May 2007
    • 5390

    #2
    hi ...

    welcome to TSDN. onclick of your checkbox you have to call a function that loops through the textboxes and set/remove the disabled attribute of them. please post some code you have done so far ...

    kind regards

    Comment

    • harig
      New Member
      • Jul 2007
      • 10

      #3
      thank u ... i've done dis already.....


      [CODE=javascript]if(document.get ElementById("sa meKwd").checked ){
      for(var i=0;i<=10;i++){
      document.getEle mentById("keywo rd"+i).disabl ed = true;
      }
      }[/CODE]

      but am getting dis error :

      document.getEle mentById("keywo rd" + i) has no properties
      Last edited by gits; Jul 23 '07, 08:19 AM. Reason: added CODE tags

      Comment

      • gits
        Recognized Expert Moderator Expert
        • May 2007
        • 5390

        #4
        do you have the ids 'keyword0' ... 'keyword10' in your document?

        have a look at the following example:

        [CODE=html]
        <html>
        <script>
        function toggle_tb_state (state) {
        for (var i = 1; i <= 4; i++) {
        var tb = document.getEle mentById('keywo rd'+i);

        if (state) {
        tb.setAttribute ('readonly', 'true');
        } else {
        tb.removeAttrib ute('readonly') ;
        }
        }
        }
        </script>
        <body>
        <input type="text" id="keyword1"/>
        <input type="text" id="keyword2"/>
        <input type="text" id="keyword3"/>
        <input type="text" id="keyword4"/>
        <input type="checkbox" onclick="toggle _tb_state(this. checked);"/>
        </body>
        </html>
        [/CODE]

        kind regards

        Comment

        • harig
          New Member
          • Jul 2007
          • 10

          #5
          thanx a lot... i've got de answer......

          Comment

          • gits
            Recognized Expert Moderator Expert
            • May 2007
            • 5390

            #6
            Originally posted by harig
            thanx a lot... i've got de answer......
            come back when you have more questions ;) ... anytime ...

            kind regards

            Comment

            • harig
              New Member
              • Jul 2007
              • 10

              #7
              hey am back.......can we do directory browsing using javascript.???? ?

              Comment

              • gits
                Recognized Expert Moderator Expert
                • May 2007
                • 5390

                #8
                Originally posted by harig
                hey am back.......can we do directory browsing using javascript.???? ?
                ;) ... that's a question besides the original problem ... so you normally should create a new thread for this. but the answer to this one is simple: you cannot! imagine a website that may retrieve the contents of any folder on you machine ... fortunatly this is not possible ;) ...

                kind regards

                Comment

                Working...