Help with LoadVars()/sendAndLoad() in my form
Hi there,
I've been trying to figure this out and the documentation is really confusing, at least to me. First, I have a basic HTML form that I am submitting with a flash button. To do that I am doing this:
Code:
(actionscript on button)
on (release) {
getURL("javascript:flashFormSubmit();");
}
(javascript in page)
function flashFormSubmit()
{
var myForm = document.forms[0];
myForm.submit();
}
That has tested to work fine. Now, the next thing I need to do is tell the server which button has been pressed, since there are multiple submit buttons. This is where things are confusing. How can I send some kind of variable to the server on post along with the form submission?
First I tried setting a variable...
Code:
set ("submitted", "pestcontrol");
But couldn't figure out how to send it. Then I found this code"
Code:
var ldata = new LoadVars();
ldata.dataToSend = "pestcontrol";
ldata.onLoad = function(success)
{
if(success){
trace(this.dataReceived);
} else {
trace("error");
}
}
ldata.sendAndLoad("self2.html?submitted=pestcontrol", ldata, "POST");
self2.html is the page I am posting to for my testing. Adding this has no effect on my page. I tried to put it after the on(release) and that did nothing either. A few things are confusing, first of all the method is POST here but the URL shown is a GET string.
Secondly, since I am submitting the form with javascript, I don't see how anything outside the HTML can be sent. How can I insert my variable to get sent along with the post?
Sorry this is convoluted but I am fairly confused - all I want to do is send a button name that can be read in the POST.
Thanks
Tom