For Loop not acting correctly...

Hi everyone,
I have this For Loop in JavaScript which is not working correctly and I really have no idea why it is acting like so... I don't if anyone has already encountered this issue and I'd like to know if there's a fix for this or what am I doing wrong...
I have a normal for until the count is done like this -> for (var c = 0; c < frmResourceReq.instanceManager.count; c++){}
If I put this loop with only a messageBox it will do it right, so if the count is 1, it will do it once, if the count is 2 it will do it twice...
The loop with the actual code is not acting like so.. if the count is 1, it will do it once, but if the count is 2 it will do it once also...
At 1 point it was acting weird so I decided to make the condition with  'c <= frmResourceReq.instanceManager.count'
Now if the count is 1, it is not working because it crashes once it execute it the second time, but if I have a count of 2 or 3 it will execute the right number of times...
Does anyone have any idea what is creating this issue, seems like I really can't figure it out.
Thanks for your time.

Hi,
to avoid that the loops condition is unnecessarily calculated again for every iteration it's recommended to save the condition in a variable first.
for (var c = 0, n = _frmResourceReq.count; c < n; c += 1) {
    //code to execute
As the instance count of iteration frmResourceReq may change already while the loop runs it can end with unexpected results.

Similar Messages

  • Javascript For loop not working within a function

    Hi all,
    I'm a beginner to LiveCycle and I cant seem to get a loop working within a function.  The function is being called successfully because when I manually create the code it works but I am trying to clean things up.
    So here is my working example:
    function hideContent() {
            MainFlowedSub.LevelsSub.Table1.presence = "hidden";
            MainFlowedSub.LevelsSub.Table2.presence = "hidden";
           ... and so on....
             MainFlowedSub.LevelsSub.Table8.Row1.presence = "hidden";
            MainFlowedSub.LevelsSub.Table8.Row2.presence = "hidden";
           ... and so on....
    However when I try and creat a loop instead of listing every sing table/row nothing happens. this is important to my project as there will be alot of different rows depending on radio button selections earlier in the form.  Below is the current state of my code:
    function hideContent() {
        var i=0;
         for (i=1;i<=5;i++)
             MainFlowedSub.LevelsSub.Table[i].presence = "hidden";
        var j=0;
         for (j=1;j<=23;j++)
             MainFlowedSub.LevelsSub.Table8.Row[j].presence = "hidden";
        var k=0;
         for (k=24;k<=88;k++)
             MainFlowedSub.LevelsSub.Table8.Row[k].presence = "hidden";
    this will then continue as there will be hundreds of rows.
    Any help will be greatly appreciated and I am sure I am making a basic error  so thanks in advance.
    j

    thanks for your help paul.  Again, really appreciated as I know very little about all this.
    Unfortunately its still not working... One thing I am sure of is that I am doing something very basic wrong. So here is my code, I have applied your suggestion above which will cover all my data:
    To give an understanding, I have 5 tables of content, each has i amount of rows. and I am running this script to clear/remove all items being displayed.
    function hideContent() {
        for (var i=1;i<=5;i++)
            xfa.resolveNode("MainFlowedSub.LevelsSub.Table[" + i + "]").presence = "hidden";
        for (var i=1;i<=71;i++)
            xfa.resolveNode("MainFlowedSub.LevelsSub.Table8.Row[" + i + "]").presence = "hidden";
        for (var i=1;i<=93;i++)
            xfa.resolveNode("MainFlowedSub.LevelsSub.Table9.Row[" + i + "]").presence = "hidden";
        for (var i=1;i<=99;i++)
            xfa.resolveNode("MainFlowedSub.LevelsSub.Table10.Row[" + i + "]").presence = "hidden";
        for (var i=1;i<=101;i++)
            xfa.resolveNode("MainFlowedSub.LevelsSub.Table11.Row[" + i + "]").presence = "hidden";
        for (var i=1;i<=87;i++)
            xfa.resolveNode("MainFlowedSub.LevelsSub.Table12.Row[" + i + "]").presence = "hidden";
    It has to be something to do with my For loops because if I manually insert each line it works perfectly.
    Thanks again,
    johnny

  • TT89 for MN - Not calculating correctly

    Hi,
    TT 89 for MN is not calculating correctlty  -   BSi Message status is as appended below.
    2000
    NO COMPANY UT EXPERIENCE RATE INFORMATION FOR THE MINNESOTA STATE UT TAX WAS FOU
    ND.   THIS TAX HAS BEEN CALCULATED USING THE BASE RATE. THIS RESULT MAY OR MAY N
    OT BE VALID FOR YOUR COMPANY
    Currently we are at TUB 52 ( Version 9.0 ) and i have iconfigured  the TT 89 in the Tax Model. Howver TT89 is not coming correctly. ( T5UTX value is .005 ) .
    With Regards,
    Abhishek

    Hello,
    Please check T5UTI for tax type 89 unemployment note down the Employer ID. Then with the Employer ID go to the T5UTH table and check if there is an entry there. If not, can you please maintain the T5UTH table with an appropriate entry for Employer ID?
    2000
    NO COMPANY UT EXPERIENCE RATE INFORMATION FOR THE MINNESOTA STATE UT TAX WAS FOUND. THIS TAX HAS BEEN CALCULATED USING THE BASE RATE. THIS RESULT MAY OR MAY NOT BE VALID FOR YOUR COMPANY
    Then this means that you haven't overrided the UT experience rate for MN state for your company 'xxxx' in the appropriate dataset in BSI Server.
    Please maintain the Company UT exp rate for NM state in the respective datasets and then run the payroll. This will solve the issue.
    Kindly maintain the BTXRATE for it at SAP side as well as BSI Side also
    Kindly maintain following in your Tax factory for your dataset --> Group Overrides  >Choose your Employee Group > Maintain record for MN.
    With regards,
    S.Karthik

  • While loop not performing correctly

    When I enter ANY number, the second while loop in the code below executes. It should not execute when 117, 239, 298, 326, or 445 is entered. I can't seem to figure out why this does not work, and I do not know what else to try.
    Hope someone can just give some assistance. Thank you!
    If I need to supply the entire program, just let me know.
    while(! done)
                   try
                        System.out.println("Enter the flight number");
                        entry = keyboard.nextInt();
                        while((entry != 117) || (entry != 239) || (entry != 298) || (entry != 326) || (entry!= 445))
                             System.out.println("Flight number must be 117, 239, 298, 326, 445");
                             System.out.println("Please try again");
                             entry = keyboard.nextInt( );
                             done = true;
                   catch(InputMismatchException e)
                        keyboard.nextLine();
                        System.out.println("Not the correct entry");
                        System.out.println("Please try again");
              }

    JosAH wrote:
    paulcw wrote:
    The outer loop loops on "not done", but in the body of that loop, done is unconditionally set to true. So the outer loop will only run once. Therefore it's pointless. I'm guessing that you meant to only set done to true if the user inputs "quit" or something.The 'not done' loop will iterate again if the user supplied incorrect input (not an int).Man that's a confusing flow of control. So if the user types in anything other than a number, it's causes a parse error (basically) and the exception causes it to skip the command to stop, and that makes it loop again.
    So apparently 3/4 of the people looking at that code didn't get it at first.
    It reminds me of the veda about Mel.
    Come up with something clearer.

  • For loop not working & way to include an external file

    Hi everyone, i am new to java and am having some problems with my program.
    I have a for loop but it doesnt work it completely gets ignored and i have
    no idea why it does that.
    IS there a way that i add another option in the menu to open an external file
    which would be similar to this but it would be for cabinBooking. If so how do
    i do that. if opening an external file is impossible then could you please show me an example of how to extend the booking class.
    Any help would be appreciated.
    Thank you very much
    import java.util.Scanner;
    import java.io.*;
    public class Booking{
    Booking(String bId,     String bName,int bNum){
    bookId = bId;
    bookName = bName;
    bookNum     = bNum;
    String bookId;
    String bookName;
    int     bookNum;
    public double calculateBookingPrice(){
    double cost     = bookNum *     genBookingcost;
    return cost;
    double genBookingcost =     80;
    public void     summary(){
         System.out.println();
    System.out.println("Booking Number is: " + bookId + ", ");
    System.out.println("Booking Made for : " + bookName);
    System.out.println("Cost of booking = $" + calculateBookingPrice());
    System.out.println();
    public static void main(String[] args) throws IOException{
    Scanner     keyboard = new Scanner(System.in);
    BufferedReader charInput = new BufferedReader
    (new InputStreamReader (System.in));
    int bookCount = 0;
    char answer;
    Booking[] bookings = new Booking[6];
    do {
         menu();
         System.out.println("book Count = " + bookCount);
         answer = charInput.readLine().charAt(0);
                   if (answer == 'a' || answer == 'A'){
                        System.out.println("Booking     ID : ");
              String idstring     = keyboard.nextLine();
              System.out.println("Booking     Name : ");
              String namestring =     keyboard.nextLine();
              System.out.println("number of people : ");
              int     ppl     = keyboard.nextInt();
              bookings[bookCount] = new Booking(idstring,namestring,ppl);
              bookings[bookCount].summary();
                        bookCount++;
                   }else if (answer == 'b' || answer == 'B'){
                        System.out.println("Enter printing");
                        bookings[0].summary();
                        bookings[1].summary();
                        // this is the loop that it is ignoring GGRRRR!!!
                   for(int i = 0; i >= bookCount; i++){
                        System.out.println("Counter: " + i);
                        bookings.summary();
                   }else if (answer == 'x' || answer == 'X'){
                        System.out.println("Exiting the programme...");
    System.out.println();
    System.exit(0);
    }while (answer != 'x' || answer != 'X');
    public static void menu(){
         System.out.println("********** Main Menu ***********");
              System.out.println(" A. Make General Booking");
              System.out.println(" B. Print Summary");
              System.out.println(" X. Exit program");
              System.out.println("*****************************");
              System.out.println("Select one of the options above");

    in order to extend the Booking class, you can create anew class like this..
    public class CabinBooking extends Booking
       public CabinBooking( /*String bId, String bName,int bNum .. more args or fewer, or none.. */)
        // add new methods or override ones from Booking
    }

  • Clip looping not working correctly unless I edit clip in Waveform editor (CS6)

    I record a short clip
    I use the, razor, slip or time selection to trim the clip to the exact length I want it to be.
    I rt-click the clip and enable looping
    I go to the right edge of the clip and stretch the clip to make it loop one or more times.
    Problem, the clip loops but not at the begin and end point I expected based on #2 above.
    I eventually went into the wave form editor and just deleted the dead air at the beginning of the clip (but not at the end) and now the looping feature works as expected.
    Am I missing something?  Is this the correct behavior?  Do I have to edit a clip in waveform editor to make it loop correctly?
    Thanks, I'm new to AA and just getting started with CS6 version.

    bmfm_ wrote:
    I have quite a lot XDCAM EX 50i clips which are all in one sequence that is used as source.
    Now fortunately one can choose to either have a sequence as source edited in nested or as individual tracks. Very nice!
    Very bad is that 3 point editing only works when "nested" is activated. Again, very bad!
    Hi bmfm,
    I think I know what's going on. The behavior you describe happens when you try to edit back into your original sequence. Can try making a new sequence to cut your selects into? See the page in help for details: http://helpx.adobe.com/premiere-pro/using/edit-sequences-loaded-source-monitor.html
    Thanks,
    Kevin

  • Looping Not Working Correctly In CS4

    In Encore CS4 I have a DVD with the first menu that is set to loop forever.  After I burn the DVD, the menu loops twice then stops.  I tried again to set the loop number to 1024.  The results were the same, the menu looping twice and stopping. 
    I've tried in four different DVD players.  In addittion, in preview mode the menu seems to loop correctly.
    Does anyone have any ideas or suggestions?

    Thank you.
    The T-Y's are as good as it gets.
    Burn speed can cause playability issues, and I normally step down to about 1/2 of the max. As no set-top player is certified to play any burned DVD, I want to eliminate as many potential problems, as I can.
    Now, I do not recall hearing of any Looping Bug in CS4, but also do not have CS4. Maybe others have experience with this issue.
    Sorry that I do not know even where to look next.
    Good luck,
    Hunt

  • Need help for style not displaying correctly in chm

    I’m using RoboHelp HTML version 8.  RH8 is dropping a style from my stylesheet.  The style appears to be applied correctly when I view a topic (the HTML file) directly with either IE or Firefox browser, and it appears correctly when I view the topic with the “Item View” feature in RH8 (the eyeglasses icon).  However, in the compiled HTML help output from RH, the style is not correct.  The style in question is a class of style (“desc” for descriptions) for a subset of table data. The “desc” class should have the data in the cell left justified, and the cell width should be 50%.  The main parent style for table data (centered text, cell width varies) seems to be applied instead, and the child style for descriptions is not applied.  Below I've included a screen shot of a table page as it looks in Item Viewer, then the same page as it appears in the CHM, and finally the style sheet in its original state before being added to RH.
    Here are things I’ve checked for:
    ·         The project is large, with over 6300 topics and a compiled chm of 5560 KB.  RH crashes when I try to apply style sheets or master pages to multiple topics from the Topic List.  However, I created a much smaller test project with 122 topics and still get the dropped style.
    ·         The style sheets were created outside of RH, and are also used for presenting the same content over the web outside of RH.  The styles display fine in the other context through a browser.  I have not modified the style sheet in RH, but I have opened it in RH.  I’ve also tried deleting and re-copying the style sheet into the project.
    ·         There is another set of styles applying to the tables, for table rows.  There is a “tr” class for the heading and classes for rotating background colors.  These child styles appear correct with no problems.  Every row in a table belongs to a child class of row styles.  In the case of table data styles, most cells require the parent “td” style and only a subclass require the child “desc” style.  It’s the “desc” style that isn’t showing up in the chm.  Is this a clue?
    ·         Multiple style sheets per topic.  Apparently only one style sheet can be used per topic.  In my project, I have two types of topics, called schema pages and table pages, with a style sheet for each.  The same master page is used for both types.  The master page uses the tables style sheet.  Therefore, the tables topics (the ones with the dropped style) use only one style sheet, but it is specified in both the master page and the topic itself.   Is this a problem?
    ·         Reviewing the style sheet in RH.  When I inspect the style sheet through RH’s Project Manager, the table data and table row styles appear under “Other” and not under “Table.”  Is this a clue?
    The special formatting of the description cells in our table-heavy project is essential.  I’ve spend days trying to troubleshoot this problem and would appreciate any help anyone can offer.

    Hi jensei,
    Thanks for that. When I took that screenshot - bizarrely those cells all had exactly the same html. I can't easily prove that now as I have tinkered with that test page quite a lot since. I started thinking maybe I could do something "clever" with table styles to save me the joyless task of manually editing all tables in my project. In the end I gave up and decided to devote a couple of hours to going through and reformatting all tables with a font that was the same size and of a similar type face to the rest of the page. Obviously not an option in your monster project, but it worked for me.
    I've seen so many random results here that I can't get my head around what exactly is going wrong - for me the issue seems connected with style = none in a table.
    Anywhere else on the page, style = none yields text with font = Tahoma 10pt.
    But in the table cells that text sometimes rendered ok in CHM, but often it would randomly appear far larger.
    So for me the cure was to format all tables with font = arial 10pt (rendered result is similar, but somehow different enough to stop the erroneous size rendering).
    That's as far as I got - as usual with time being very precious, I've had to curb my geekiness and crack on.
    Cheers,
    Andy

  • Loop not working correctly in smartform

    Hi Experts,
    I have developed a smart form wherein,  the import params of form is a table (multiple records).The design of the form is, the first 10 lines is populated with a static text followed by the import table and follwed by a conclusion text. in simple words the design is, in the header a static text (hard coded text) will be populated in the main body an internal table will be populated and in the footer a static text (hard coded text) will be populated.Initially I have created three seperate windows for header, main body and footer, this was working fine for few records (import table) sometimes it happened the records were very huge and table entries over lapped the footer text. How to handle this kind issue? Can we increase the page size dynamically?? and also as per the user requirement the output of the form should have a provision to download the form on thier desktop in word format. Can some one help me in building this functionality.
    Thanks and Regards,
    Srini...

    Hello Mr. Srinivas,
    There is no provision to download the form in word format, but if you want to still download the form in real means open smartforms --> Utilities(M) --> download form.
    this will download the whole program wahtever you hvae chnge made in this. Make the back copy of form and after edition in form make down load again this form and than find out the differnce. May be this will be helpful. And also if yr loop is not working with smartform. Do write the similar code in yr driver program for the loop this will definetely helpful.
    Regards,
    Akg
    Edited by: akg.amit on Mar 25, 2011 10:08 AM

  • Current Period" attribute for Variants not working correctly

    Hi Expert,
    Pls i need your advice on the issue screenshot below.
    When creating variants, a dynamic screen selection can be chosen for “Current Period” that will pre-populate begin and end dates. The problem is that, this attribute gives calendar month dates, not our company accounting period dates i.e. 4-4-5.
    Can this be corrected?
    I have an option to create the fiscal year variant to fix the problem but am not sure on how to go about that.
    Pls advice.
    Regards
    Femmy John.

    Hi Marssel,
    Thank you for the quick respond.
    Kindly explain to me the importance of using this field period and execute same setup?
    will this populate our company accounting period dates i.e. 4-4-5.
    I just want to get the fact right before going to the customer.
    Regards
    Femmy John

  • Loops not playing correctly when added to project

    When I listen to loops in the library (specifically drums) they sound fine. I drag them over to my project and get a pop-up saying: "EXS24 instrument "2-Step Remix.exs" not found." The loop is added to my project, but now sounds odd and distorted. How can I fix this?

    Seems like you are having problems with accessing Logic's library content (if you have it all installed of course). That can be resolved by checking/repairing disk permissions.

  • Interactive report filter for date not working correctly

    Hi,
    I am having an interactive report. I tried to give a filter for a column(created_on) as created on>29-oct-2009 17:17
    but i am getting the row containing created on as *29-oct-2009 17:17* in the report result. How can i correct this
    problem
    Thanks,
    TJ

    Hi,
    I think it is because seconds.
    So it is 29-oct-2009 17:17:00 and your record is e.g. 29-oct-2009 17:17:02
    br, Jari
    Edit
    You can use trunc function in your select so that it round date to minutes
    TRUNC(created_on,'MI') AS created_onBr, Jari
    Edited by: jarola on Nov 5, 2009 3:02 PM

  • Why is the character style for hyperlinks not displaying correctly in design mode/viewing/output?

    I am using RH9 and generating WebHelp, and I needed to globally bump up the font size of just my hyperlinked text. I went into my Style Sheet > Character tab, changed the font size of the various character settings for hyperlinks, and clicked Apply and then OK. Normally, this would change all of my hyperlink text font sizes immediately across all of my topics. However, this time, it made no changes to any existing hyperlinked text, and it only affected new hyperlinks that I subsequently added. For the existing hyperlinks, I can only manually change the font size of the each hyperlink one at a time, but that's crazy (there's 100's in this help).
    I can successfully change other characters styles and paragraph styles. This issue only affects the hyperlink character styles. It also shows up in all RH modes - Design mode, viewing, and in the final output.
    Is this an indication of a corrupted style sheet or some other combination of events that I have yet to discover?

    Hi,
    You probably have inline styling in your project overwriting the font size of your style sheet. How are you changing the font size of the individual hyperlinks?
    There is a workaround for inline styling: Open your CSS in notepad and add !important after the font-size:
    font-size: 4pt !important;
    Note that this is a workaround, not a solution. As a solutions you can remove all the style attributes from your hyperlinks to force them to take the CSS styling again.
    Greet,
    Willam

  • Quick look for pdf not working correctly in mountain lion

    I'm running 10.8.2 and have this problem on several Macs. Many of my pdf files are not viewable with quick look. Only a large blank space is shown for the page when I hit the space bar once. If I hit the space bar to close the blank view and then hit the space bar again, the image of the PDF pops up as it should. Is this a known bug?
    Mark

    I'm running 10.8.2 and have this problem on several Macs. Many of my pdf files are not viewable with quick look. Only a large blank space is shown for the page when I hit the space bar once. If I hit the space bar to close the blank view and then hit the space bar again, the image of the PDF pops up as it should. Is this a known bug?
    Mark

  • Editing a for loop to print correctly

    I have the following code
    public void printReceipts(){
              JOptionPane frame = new JOptionPane();
              for(int i = 0; i < borrowersList.size();i++){
                   for(int j = 0; j < books.size();j++){
                        if(borrowersList.get(i).getLibraryNumber().equals(books.get(j).getLibraryCardNumber())){
                             milliLate = (tempDate.getTime() - books.get(j).getReturnDate().getTime());
                             daysLate = (milliLate/ 86400000);
                             bookDebt = (daysLate * 2);
                             borrowersList.get(i).setDebt(bookDebt);
                             JOptionPane.showMessageDialog(frame, borrowersList.get(i).getName() + "\n"
                                       + borrowersList.get(i).getStreetAddress() + "\n"
                                       + borrowersList.get(i).getPostalCode() + " "
                                       + borrowersList.get(i).getCity() + " \n"
                                       + "\n" + "As of today " + tempDate + " you owe \"The little library \"" +borrowersList.get(i).getDebt() + " kr for the books."  + "\n"
                                       + "\n" + books.get(j).getAuthor() + " " + books.get(j).getTitle() + ", amount due "+ bookDebt +
              }which prints borrowers that owe the library money.
    The problem is that if a borrower has 2 books, it will print the loop each time with the different book.
    i.e
    Wile E. Coyote
    The Second Valley from the Left
    987 65 The Desert
    As of today 2007 09 20 you owe "The little library" 300 kr for the books
    James Joyces Ulysses, amount due 96:-
    Wile E. Coyote
    The Second Valley from the Left
    987 65 The Desert
    As of today 2007 09 20 you owe "The little library" 230 kr for the books
    Fyodor Dostoyevsky Crime and Punishment, amount due 134:-
    I would like it to print out only once for each borrower
    i.e.
    Wile E. Coyote
    The Second Valley from the Left
    987 65 The Desert
    As of today 2007 09 20 you owe "The little library" 300 kr for the books
    James Joyces Ulysses, amount due 96:- (book line)
    Fyodor Dostoyevsky Crime and Punishment, amount due 134:-
    Aldous Huxley Brave New World, amount due 70:-
    So I need to store all the book lines of each borrower and then call them once all the borrowed books debts have been assigned.

    Implode wrote:
    CeciNEstPasUnProgrammeur wrote:
    You could have a method that takes the list of books (or even the borrower) and provides you with a String containting all you want to print... then you'd call this method only once and print out what you want.I thought of this, but I would need each book line to be on a separate line?
    public void setPrintDetails(String row){
              this.row = row + this.row
    Use a StringBuilder/StringBuffer:
    private StringBuilder details;
    public void setPrintDetails(String row) {
       details.append(row).append("\n");
    }You could also use the line.separator property instead.

Maybe you are looking for

  • TA27369 how do you see the server monitor application

    I am trying to troubleshoot on an Xserve.  Cannot see the drive and triangle light is blinking.  My search tells me to view the server monitor application.  What is this and where can I find it if I am unable to see the hard drives? 

  • Hotmail,text messages and an N95

    I have configured my hotmail account to send me a text message whenever I get specific emails.The trouble is that it only sends one line of the email and I have to send a text message reply to get more of the email.This is very time consuming and exp

  • Can't click desktop icons

    Sometimes after sleep all the desktop icons (disks, folders, documents, etc...) are unresponsive and the only way to fix it is to restart. This doesn't happen on my other machines. Anyone else experience this issue and know a possible fix?

  • Business Objects on Virtual Machines

    Hi, We are setting up new servers for our Business Objects to accomodate the DEV/TEST and PROD environments. Can we use Virtual Machines (VM Servers) for both the DEV/TEST and PROD environments? Thanks.

  • How to shrink the MS SQL 2005 Databse.

    how to shrink the ms sql server 2005 databse on windows 2003 server?