Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Sep 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    consecutive checkbox

    Hi ,

    plz do help me for checking the consecutive checkboxes in a group of checkbox (or for 7 days of week) using if loop.


    Regards,

    Ajay

  • #2
    Senior Coder
    Join Date
    Dec 2010
    Posts
    2,396
    Thanks
    12
    Thanked 569 Times in 562 Posts
    Where is your code?

  • #3
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,910
    Thanks
    203
    Thanked 2,531 Times in 2,509 Posts
    What is an if loop????

    Code:
    <form>
    <input name = "myname" type = "checkbox" value = "Sunday"> Sunday <br>
    <input name = "myname" type = "checkbox" value = "Monday"> Monday <br>
    <input name = "myname" type = "checkbox" value = "Tuesday"> Tuesday <br>
    <input name = "myname" type = "checkbox" value = "Wednesday"> Wednesday <br>
    <input name = "myname" type = "checkbox" value = "Thursday">Thursday <br>
    <input name = "myname" type = "checkbox" value = "Friday"> Friday<br>
    <input name = "myname" type = "checkbox" value = "Saturday"> Saturday<br>
    <br>
    <input type = "button" value = "Get Day Choices" onclick="cboxlist()"><br>
    </form>
    
    <script type = "text/javascript">
    
    function cboxlist(){
    var choice = "Your choice of day(s) is: ";
    var chosen = [];
    var weekdays = document.forms[0].myname;
    for ( i = 0; i < weekdays.length; i++ ) {
    if ( weekdays[i].checked ) {
    chosen.push(weekdays[i].value);
    }
    }
    alert (choice + (chosen.length == 0 ? 'NONE' : chosen.join(' | ')));
    } 
    
    </script>

    Q: How do you keep an idiot in suspense?
    A: I'll tell you later
    Last edited by Philip M; 09-05-2012 at 10:56 AM.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  • #4
    New to the CF scene
    Join Date
    Sep 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    hi Philip thanks for info...

    Hi,
    sorry for incomplete que, How to check CONSECUTIVE checkboxes in extjs3.4? That means It should allow very next and previous checkboxes and other should be readonly.

    Thanks and Regards,
    Ajay


    Quote Originally Posted by Philip M View Post
    What is an if loop????

    Code:
    <form>
    <input name = "myname" type = "checkbox" value = "Sunday"> Sunday <br>
    <input name = "myname" type = "checkbox" value = "Monday"> Monday <br>
    <input name = "myname" type = "checkbox" value = "Tuesday"> Tuesday <br>
    <input name = "myname" type = "checkbox" value = "Wednesday"> Wednesday <br>
    <input name = "myname" type = "checkbox" value = "Thursday">Thursday <br>
    <input name = "myname" type = "checkbox" value = "Friday"> Friday<br>
    <input name = "myname" type = "checkbox" value = "Saturday"> Saturday<br>
    <br>
    <input type = "button" value = "Get Day Choices" onclick="cboxlist()"><br>
    </form>
    
    <script type = "text/javascript">
    
    function cboxlist(){
    var choice = "Your choice of day(s) is: ";
    var chosen = [];
    var weekdays = document.forms[0].myname;
    for ( i = 0; i < weekdays.length; i++ ) {
    if ( weekdays[i].checked ) {
    chosen.push(weekdays[i].value);
    }
    }
    alert (choice + (chosen.length == 0 ? 'NONE' : chosen.join(' | ')));
    } 
    
    </script>

    Q: How do you keep an idiot in suspense?
    A: I'll tell you later

  • #5
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,910
    Thanks
    203
    Thanked 2,531 Times in 2,509 Posts
    Quote Originally Posted by ajaynayak7 View Post
    Hi,
    sorry for incomplete que, How to check CONSECUTIVE checkboxes in extjs3.4? That means It should allow very next and previous checkboxes and other should be readonly.

    Thanks and Regards,
    Ajay
    No idea what extjs3.4 is. Could you please give a clearer example of what you require. What if the first/last checkbox is checked?? Show your HTML.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  • #6
    Senior Coder Logic Ali's Avatar
    Join Date
    Sep 2010
    Location
    London
    Posts
    1,028
    Thanks
    0
    Thanked 207 Times in 202 Posts
    Quote Originally Posted by ajaynayak7 View Post
    Hi,
    That means It should allow very next and previous checkboxes and other should be readonly.
    The question still isn't clear, but is this anywhere close?
    Code:
    <body>
    <form id='myForm'>
    <input name = "theDay" type = "checkbox" value = "Sunday"> Sunday <br>
    <input name = "theDay" type = "checkbox" value = "Monday"> Monday <br>
    <input name = "theDay" type = "checkbox" value = "Tuesday"> Tuesday <br>
    <input name = "theDay" type = "checkbox" value = "Wednesday"> Wednesday <br>
    <input name = "theDay" type = "checkbox" value = "Thursday">Thursday <br>
    <input name = "theDay" type = "checkbox" value = "Friday"> Friday<br>
    <input name = "theDay" type = "checkbox" value = "Saturday"> Saturday<br>
    </form>
    
    <script type = "text/javascript">
    
    (function( boxes )
    {
      var today = new Date().getDay(),
          diff;
    
      for( var i = 0, len = boxes.length; i < len; i++ )
        boxes[i].disabled = ( diff = Math.abs( i - today )  ) > 1  && ( diff != len-1 ); 
     
    })( document.getElementById( 'myForm' ).theDay )
    
    </script>
    
    </body>


  •  

    Posting Permissions

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