I have attached a form to a dhtmlx window obkect via attachURL() and this page has a standard HTML form on it.
Is there a way I can submit this using send()?
form attached like this:
myWindow.attachURL("form.php", true);
I have added an onclick event to the button on the form which calls a function
onclick="processFrom()";
Inside processFrom() I have tried the following:
var form = document.getElementById("myForm"); // The ID of the form
form.send("process-form.php,"post",function(loader, response){
console.log(response);
});
all i get is an error saying form.send is not a function
thanks for your help but i couldn’t seem to get this to work it must have been the way I’ve coded it.
My solution was to pass the form back to my script file from the form button
onclick="processHTMLFrom(document.myForm);
and as the form is a simple list of radio groups I then looped through the elements storing the checked values and keys in an abject.
function processHTMLFrom(form){
var formElms = {};
for (var i = 0; i < form.elements.length; i++ ) {
if (form.elements[i].type == 'radio') {
if (form.elements[i].checked == true) {
var keyData = form.elements[i].id.split('_');
formElms[keyData[0]] = form.elements[i].value;
}
}
}
}
I then stringifed the object with JSON
var formElmsStr = JSON.stringify(formElms);
and finally sent the values to my processing PHP script via AJAX
var r = window.dhx4.ajax.post("process-form.php", "formElms="+ formElmsJSON +"&nextSlideID="+nextSlideID, function(response){
console.log(response.xmlDoc.responseText);
});