Steve Garlick
12-08-2009, 05:44 AM
Hi , first post.
I'm trying to send data back to a database that's encoded in javascript objects on a page.
I've used this approach to fill in a pseudo form and submit the results to several php files to update the database. Everything works fine, done one at a time. When I call this type of function inside another loop to feed multiple objects to the database, only the first record is inserted. I'm wondering if there are latency issues with multiple submits?
function postwith (to,p) {
var myForm = document.createElement("form");
myForm.method="post" ;
myForm.action = to ;
for (var k in p) {
var myInput = document.createElement("input") ;
myInput.setAttribute("name", k) ;
myInput.setAttribute("value", p[k]);
myForm.appendChild(myInput) ;
}
document.body.appendChild(myForm) ;
myForm.submit() ;
document.body.removeChild(myForm) ;
};
Maybe I'm barking up the wrong tree. Is there an easier way to pipe arrays of javascript objects back into multiple database tables?
Regards,
Steve Garlick
I'm trying to send data back to a database that's encoded in javascript objects on a page.
I've used this approach to fill in a pseudo form and submit the results to several php files to update the database. Everything works fine, done one at a time. When I call this type of function inside another loop to feed multiple objects to the database, only the first record is inserted. I'm wondering if there are latency issues with multiple submits?
function postwith (to,p) {
var myForm = document.createElement("form");
myForm.method="post" ;
myForm.action = to ;
for (var k in p) {
var myInput = document.createElement("input") ;
myInput.setAttribute("name", k) ;
myInput.setAttribute("value", p[k]);
myForm.appendChild(myInput) ;
}
document.body.appendChild(myForm) ;
myForm.submit() ;
document.body.removeChild(myForm) ;
};
Maybe I'm barking up the wrong tree. Is there an easier way to pipe arrays of javascript objects back into multiple database tables?
Regards,
Steve Garlick