0

these loops are iterating through arrays.

arrayFinalValues = [];
    $(arrayAccessRightID).each(function (i, val) {
        $(arrayNodeID).each(function (j, val1) {
            arrayFinalValues.push(val);
            arrayFinalValues.push(val1);
            $(arraySelectedValues).each(function (k, val2) {
                arrayFinalValues.push(val2);
                if (arrayFinalValues.length % 6 == 0)
                    return false;
            });
        });
    });

in the inner most loop when six elements are entered i want again to start from the outermost loop and in the inner most loop the index should start from next 4th element i.e., i want to in the structure 1,1,T,T,F,F,1,2,F,F,F,F. and so on. that is in the inner most loop the index should start from next elements.when i use return false in inner most loop it again starts with 0.i tried labels but its now working.

2
  • 1
    this might help you stackoverflow.com/questions/1564818/… ? Commented Mar 26, 2014 at 10:42
  • @PratikJoshi: break has no effect on jQuery's each. Putting it anywhere in the OP's quoted code would be a syntax error. Commented Mar 26, 2014 at 10:45

1 Answer 1

2

Try this, taken from here

$(arrayAccessRightID).each(function (i, val) {
    var shouldExit = true;
    $(arrayNodeID).each(function (j, val1) {
        arrayFinalValues.push(val);
        arrayFinalValues.push(val1);
        $(arraySelectedValues).each(function (k, val2) {
            arrayFinalValues.push(val2);
            if (arrayFinalValues.length % 6 == 0)
            {
              shouldExit = false;
              return shouldExit;
            }
        });
        return shouldExit;
    });
    return shouldExit;
});
Sign up to request clarification or add additional context in comments.

6 Comments

I'm not saying you copied it (from me, I mean), don't get the wrong idea. I'm just saying that now that's it's corrected, it's redundant rather than incorrect.
@T.J.Crowder here is the post I borrowed the code from : stackoverflow.com/a/12161949/1182982
I thought you actually Answered yourself ,you just googled it :(
Nice catch on the fact there are three loops. I didn't notice that.
the solution is not working.already googled but not found anything helpful :(
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.