DHTMLX Docs & Samples Explorer

Submitting/Saving Form Data

There are three variants to deal with form data using dhtmlxForm:

  1. submit form in common way.
  2. send data via AJAX request (get or post)
  3. integrate dhtmlxForm with dhtmlxConnector to insert/update/delete in automatic mode

All these ways can be initialized through event handlers of dhtmlxForm associated with various elements and onButtonClick event, associated with 'button' element in particular.

send data on proc.php when user clicks button with name //my_submit_button//
myform.attachEvent("onButtonClick", function(name, command){
  if(name=="my_submit_button"){
          this.send("proc.php");
    }
});

You also can use button commands which can be specified in command attribute of button element for some common actions. They are:

  • save - the same as to call save() method (see integration with dhtmlxConnector for details)
  • validate - runs validation for each field in the form which has validation rule associated with it
  • reset - clears the latest changes (like 'reset' button of HTML form)
  • remove - the same as to call removeItem() method (see integration with dhtmlxConnector for details)
  • any custom command name - command name is passed into onButtonClick event handler as the second argument and can be used there.

Send data using AJAX request

DhtmlxForm provides the ability to send its data to server using AJAX request (GET or POST) and then process reply with send() method.

dhxForm.send("some.php");
//or
dhxForm.send("some.php","post");
//or
dhxForm.send("some.php","post",function(xml){
alert("Saved");
});