DHTMLX Docs & Samples Explorer

Submitting/Saving Form Data

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

  1. submit html 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 the command attribute of a 'button' element for some common actions. They are:

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

HTML form submitting

In case you've based a dhtmlxForm object on the existing html form you can deal with the form like with any HTML one:

  1. use button type 'submit' to submit data to the server
  2. use 'yourHTMLForm.submit()' to submit data with a javascript command

If you initialize dhtmlxForm from configuration structure, you still can add <form> tag around the container and use the same two ways to submit data to server.

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");
});