dhtmlxconnector:formconnector_usage [DHX documentation]

PHP Connector DHTMLX

dhtmlxConnector for form


	<link rel="STYLESHEET" type="text/css" href="../codebase/dhtmlx.css">
	<script  src="../codebase/dhtmlx.js"></script>	
	<script type="text/javascript" src="../codebase/connector.js"></script>
	<div id="box" style="width:250px; height:160px; background-color:white;"></div>
<script type="text/javascript">
//---form configuration. Defining controls
	formData = [
				{type: "block", list:[
				{type: "fieldset",  name: "mydata", label: "Customer details", width:235, list:[
					{type: "input", name:"name", label: "Name",  labelWidth:50, inputWidth:130},
					{type: "input", name:"address", label: "Address",  labelWidth:50,  inputWidth:130},
					{type: "input", name:"email", label: "Email",  labelWidth:50,  inputWidth:130},
					{type: "button", name:"save", offsetTop:10,  value:"Submit"}
				{type: "block", list:[
				{type: "button", name:"button1", value:"Customer 1", offsetTop:10,width:80},
				{type: "button", name:"button2", value:"Customer 2", offsetTop:10,width:80}]}
//---form initialization
	var myForm = new dhtmlXForm("box",formData);//object constructor
//---loading data from db. 
        myForm.load('formdata.php?id=1');// as the parameter is a connector file with the id of loading record
//---dataProcessor initialization	
	var mydp = new dataProcessor ("formdata.php");// object constructor. Here you should specify a connector file
	mydp.init(myForm);// initializes dataProcessor. As the parameter you should specify your grid
	myForm.attachEvent("onButtonClick", function(id){
			if (id=='button1'){//
				myForm.load('formdata.php?id=1')// loads data of the first customer. The record with the id=1
			else if (id=='button2'){
				myForm.load('formdata.php?id=2')// loads data of the first customer. The record with the id=2
			else if (id=='save'){
				myForm.save();// saves data to db


  $conn = new FormConnector($res,"MySQL");
  $conn->render_table("customers","id","name, address, email");