delay in data loading

Hi,

  i want to add a new data in the form 
 
  when i click the add button the 
  1.form should be reloaded
  2.extract the id from the input box loaded
  3.clear the form
  4.add 1 and set it in the input box

if(id==‘add’){
form_Vendor_Info.load(‘FormVendorInfo.do’);
form_Vendor_Address.load(‘FormVendorAddress.do’);

	var vid = parseInt(form_Vendor_Info.getItemValue("VENDOR_ID"))+1;
			
	form_Vendor_Info.clear();
	form_Vendor_Address.clear();
	grid_Contact.clearAll();
			
	form_button.enableItem("cancel");
	form_button.enableItem("save");
			
	form_button.disableItem("prev");
	form_button.disableItem("next");
	form_button.disableItem("update");
	form_button.disableItem("add");
			
	form_Vendor_Info.setItemValue("VENDOR_ID",vid);
	form_Vendor_Info.disableItem("VENDOR_ID");
	form_Vendor_Address.setItemValue("VENDOR_ID", vid);

}

The above code doesn’t work correctly because it loads the data after the other operations are performed…

Hello

Form’s load func have callback, 2nd param, like this:

myForm.load(‘php/data.php?id=1’, function(){
/* code will executed after data loaded */
});

Thank u … i have done