load combo before load data form

I have a form that contains input fields and six combo fields .
When I load the form, before I have to load the data of the combo, and only after loading the form data.




but in this way, the load of the form begins before the load of some combo, with the result to have some combo empty.
How can I do, to start the load of the form only if the load of the combo is over

I also tried to delay window.setTimeout with the load of the form, but without success



That’s correct, with async loading such behaviour is possible.

Try the following:

  1. specify “connector” attr to combo in a formStruct instead of combo1.load()
  2. load formStruct and then load formData in callback


var myForm = new dhtmlXForm("parent_id"); myForm.loadStruct([...]); myForm.load("loadform.php?E=a"); // or via callback if loading from url myForm.loadStruct("url", function() { myForm.load("loadform.php?E=a"); });

Andrei thank you for your response.
I was trying to do



This way it seems to me (I have to check) work well.
What do you think about it ?
the approach you suggested allows you to write code more readable instead my code is really complex.

Thanks again for your help

this approach will also work, but it will required to add more code or remove existing code if you have to add say combo7 and combo8 or remove combo3 and combo4.

form have inner mechanism which ‘save’ value while combo not loaded and later fill it after data filled. here is a demo