windows.getID function returning same ID..

Hi everyone!!
Ok, so I have 4 windows, each with a toolbar (which were created in a cycle).
When i click the “save” button I want to get the windows ID… problem is that I always get the same window id “3” which was the last one created in the cycle.I’m pretty sure the problem is in the cycle somewhere. but i have no clue as to where…below is the code;

for (i = 0; i < 4; i++) {
if (!dhxWin.isWindow((“win” + i))) {

        var x, y, text;

        switch (i) {
            case 0:
                text = " Graph 1";
            case 1:
                text = " Graph 2";
            case 2:
                text = " Graph 3";
            case 3:
                text = " Graph 4";

        Win = dhxWin.createWindow(("win" + i), x, y, winWidth, winHeight);
        dhxWin.window(("win" + i)).keepInViewport(true);
        dhxWin.window(("win" + i)).setText(text);
        toolbar = dhxWin.window(("win" + i)).attachToolbar();
        toolbar.addButton(("btnSave"+i) , 9, "Save to Grid", "imgs/save.png", "imgs/savepressed.gif");
        var button =("btnSave"+i);<--------------------------------tried it without this also
        toolbar.attachEvent("onClick", function(button) {<----and changed this back to btnsave

            var x = Win.getId();


I’ve also changed this
toolbar.addButton((“btnSave”+i) , 9, “Save to Grid”, “imgs/save.png”,
to this
toolbar.addButton(“btnSave” , 9, “Save to Grid”, “imgs/save.png”, and nothing…


Your code works fine on our side.
Win.getId() returns different ids. (43 KB)

The sample you ran doesn’t have the toolbar included… The problem might be there, still unresolved… Thanks alot though…

I fixed it… changed the loop cycle… the problem was the “Win” variable was being re-initialized each time in the cycle…