save multiple forms in a loop

Hi,

I’ve got this code below, it is working, but it’s only saving the last (appliance) form.

Anybody know how i can fix this?

[code]var dhxAccord = dhxAutoJobTabbar.cells(“a3”).attachAccordion();
var Appliances = dxhFormAutoJob2.getItemValue(“Appliances”);
for (var i=0; i<Appliances; i++)
{
var a = i+1;
var dxhFormApp = “dxhFormApp”+a;
dhxAccord.addItem(“a” + a + “”, "Appliance " + a + “”);
var dxhFormApp = dhxAccord.cells(“a” + a + “”).attachForm();
dxhFormApp.loadStruct(“XML/Forms/JobWizzard-3.xml”);
dxhFormApp.enableLiveValidation(true);
dxhFormApp.attachEvent(“onButtonClick”, function (cmd)
{ //create event handler to save data on button click
if (cmd == “Next”)
{ // start cmd
if(dxhFormApp.validate())
{
dxhFormApp.send(“XML/Forms/ReportAppliancesSave.php”, “get”, function(loader, response)
{
dhtmlx.message(“The appliances are saved!”);
dhxAutoJobTabbar.setTabActive(“a4”);
}
);
}
else
{
dhtmlx.alert(“You need to fill in all the required fields.”);
}

                                        } // end cmd
                                } // end onbutton click
                            );
                          }
                        dhxAccord.openItem("a1");
                        dhxAutoJobTabbar.setTabActive("a3");[/code]

Thanks in advance!

Hi
There is not enough data to chek it.
Please, provide the whole page.

Hi,

It’s this part i need to get working:

for (var i=0; i<Appliances; i++)
                              {
                                var a = i+1;
                                var dxhFormApp = "dxhFormApp"+a;
                                dhxAccord.addItem("a" + a + "", "Appliance " + a + "");
                                var dxhFormApp = dhxAccord.cells("a" + a + "").attachForm();
                                dxhFormApp.loadStruct("XML/Forms/JobWizzard-3.xml");
                                dxhFormApp.enableLiveValidation(true);
                                dxhFormApp.attachEvent("onButtonClick", function (cmd) 
                                    { //create event handler to save data on button click
                                        if (cmd == "Next") 
                                            { // start cmd
                                                if(dxhFormApp.validate())
                                                    {
                                                        dxhFormApp.send("XML/Forms/ReportAppliancesSave.php", "get", function(loader, response)
                                                            {
                                                            dhtmlx.message("The appliances are saved!");
                                                            dhxAutoJobTabbar.setTabActive("a4"); 
                                                            }
                                                        );
                                                    }
                                                    else
                                                    {
                                                        dhtmlx.alert("You need to fill in all the required fields.");
                                                    }



                                            } // end cmd
                                    } // end onbutton click
                                );
                              }

It generates a few forms:

for (var i=0; i<Appliances; i++)
                              {
                                var a = i+1;
                                var dxhFormApp = "dxhFormApp"+a;
                                dhxAccord.addItem("a" + a + "", "Appliance " + a + "");
                                var dxhFormApp = dhxAccord.cells("a" + a + "").attachForm();
                                }

But when saving the forms, it will only save the last form, does anybody know a better way how to generate a dynamic amount of forms?

Hi

we need completed working demo including all corresponding js/css files, directly link also good. some words how to reproduce. you can send it to support@dhtnlx.com if any.