Hello, I want to use an empty form to insert now data in a db.
But it only works when I include the id field and fill in an id by hand…
When I don’t nothing gets saved upon pressing the save button. Is there a mistake in my code maybe?
Here is my code:
[code]var myForm, formData;
function doOnLoad() {
formData = [
{type: “input”, label: “completion %”, name: “completion_percentage”, value: “”},
{type: “button”, value: “submit”, name: “submit”},
];
myForm = new dhtmlXForm(“myForm”, formData);
var dp_f = new dataProcessor("<?php echo bloginfo('template_url'); ?>/jtc/task_action_conn.php");
dp_f.init(myForm);
myForm.attachEvent(“onButtonClick”,function(buttonID){
if(buttonID==“submit”){
myForm.save();//no params needed.It uses url that you passed to dataprocessor
}
});
}[/code]
And my connector:
[code]$conn=mysql_connect($mysql_host,$mysql_user,$mysql_pasw);//connects to server containing the desired DB
mysql_select_db($mysql_db); //connects to DB.‘sampledb’ is the name of our DB
$form = new FormConnector($conn);
$form->render_table(“wp_task_actions”,“id”,“completion_percentage,duration_hours,taskaction_notes,taskaction_user,id_task”);[/code]
In the documentation I can only find ways to edit data loaded in a form, but not how to open an empty form and insert it as new without having to fiddle with the id (because mysql autoincrements this anyway…)
I hope someone can help me with this!
Best regards.