Load Form, Insert on Button Click


#1

I’m loading data from a database to a form.
On button click I want to insert the form in the the database

I’ve read documentation for dataProcessor and dhtmlxConnector however I cannot find a correct method to insert the form.
My attempts to perform this action have resulted in updating the existing entry rather than inserting a new one

Can I have some assistance please?


#2

This is something you can use until you find a solution. Its been a while for me so i apologize.

Create your form data “formData=[]”.
remember to set the names on each type. Ex {type: “combo”, name: “playername”, label: “Playername”, required:true}

This is where i use attachEvent to save the information. Until i figure that out myself, i just use this. I send the information and retrieve it in JSON format.


myForm.attachEvent("onButtonClick", function(name){
    if(name=="submit"){
        if(myForm.validate()) { //Make sure the required fields are filled in
            myForm.send("add.php", "post", function(loader, response) {
                if(response.type == "0") {
                    alert(response.reason);
                } else {
                    myForm.clear();
                }
            })
        }
    }
});
 

for the add.php set the POST variables.
$a = $_POST[“forminput name”];
//insert into database.

echo the response if you want.
$result = array(‘reason’=>‘Report added.’);
echo json_encode($result);

Let me know if you need anything else.