SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Addict ketting00's Avatar
    Join Date
    Jul 2011
    Posts
    312
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    How do I limit clients to only 4 with the codes below

    Hi guys,
    Here's the codes
    Code:
    var clients[];
    for(var i = 0; i < clients.length; i++) {
         clients.someFunction();
    }
    I want only 4 clients at the time.

    Thanks

  2. #2
    SitePoint Addict
    Join Date
    Apr 2011
    Posts
    266
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Hi,
    Try add break; instruction:
    Code:
    for(var i = 0; i < clients.length; i++) {
      clients.someFunction();
      if(i  == 3) break;
    }
    Free: Web Programming Courses HTML, CSS, Flash
    Web Programming: AJAX Course and PHP-MySQL Course video Lessons
    Good JavaScript and jQuery course for beginners

  3. #3
    SitePoint Addict ketting00's Avatar
    Join Date
    Jul 2011
    Posts
    312
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Hi,
    Thanks for reply. I've got it done with the codes below:
    Code:
    var clients[];
    for(var i = 0; i < clients.length; i += 4) {
         clients[i].someFunction();
    }

  4. #4
    SitePoint Guru
    Join Date
    Sep 2006
    Posts
    731
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by ketting00 View Post
    Hi,
    Thanks for reply. I've got it done with the codes below:
    Code:
    var clients[];
    for(var i = 0; i < clients.length; i += 4) {
         clients[i].someFunction();
    }
    If that's the answer, then the question should have been: "How do I call a method of every fourth element?".
    What you asked was too vague to interpret.
    Tab-indentation is a crime against humanity.

  5. #5
    SitePoint Addict ketting00's Avatar
    Join Date
    Jul 2011
    Posts
    312
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Sorry,
    I create a live javascript session for group of my clients discussion. I want to limit group participation to only 4 persons. And that what I can think of at the moment.


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
  •