Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ASP / LoadVars process validation problems

Status
Not open for further replies.

boab

Programmer
May 30, 2001
75
GB
Guys the code below is driving me nuts!

What the code is supposed to do is when a submit button is clicked the data collected in the flash movie is passed to an ASP page where the data is checked and validated to make sure that the correct number of entries have been passed to the page if not the page returns result=0 (false) otherwise the page returns result=1 true the problem I am have is that the flash movie I am using will not read the result variable from the page This code worked fairly well with PHP unfortunately I have had to move to ASP and I have converted the serverside stuff ok but the link between the two has been lost. I have posted the code below any suggestions are gratefully recieved.



function submitButton_fn() {
trace("submitButton");
this._parent.dataCollector = new LoadVars();
dataCollector.onLoad = function($sucess) {
trace($sucess);
for (i=1; i<=6; i++) {
_root["page"+i]._visible = false;
}
_root.submitted._visible = true;
_root.prev_btn._visible = false;
_root.submit_btn._visible = false;
if (parseInt(this.result) == 1) {
_root.submitted.text = "Your form has been submitted.";
//+newline+this.sql+newline+"result="+this.result;
} else {
_root.submitted.text = "Your form has not been submitted. Please try again later.";
//+newline+this.sql+newline+"result="+this.result;
}
};
collectData();
for (a in this._parent.dataCollector) {
trace(a+"="+this._parent.dataCollector[a]);
}
this._parent.dataCollector.sendAndLoad("postformmailer.asp", this._parent.dataCollector, "POST");
}


THe Start of wisdom is to realise you know nothing. I'll be a genius then!
 
Try this. References to the dataCollector object should all be contained withing the onload function. (excpet the call to execute the sendAndLoad. Also I removed the this._parent which should not be necessary and was not consistantly used.

Notice the change to the "result" variable.

I can't test it so you may have to tweek it a bit. Hope it helps.

Code:
function submitButton_fn() {
	trace("submitButton");
	dataCollector = new LoadVars();
	dataCollector.onLoad = function(success) {
		trace(success);
		for (i=1; i<=6; i++) {
			_root["page"+i]._visible = false;
		}
		_root.submitted._visible = true;
		_root.prev_btn._visible = false;
		_root.submit_btn._visible = false;
		if (parseInt(dataCollector.result) == 1) {
			_root.submitted.text = "Your form has been submitted.";
			//+newline+this.sql+newline+"result="+this.result;
		} else {
			_root.submitted.text = "Your form has not been submitted. Please try again later.";
			//+newline+this.sql+newline+"result="+this.result;
		}
		collectData();
		for (a in dataCollector) {
			trace(a+"="+ dataCollector[a]);
		}
	};
	dataCollector.sendAndLoad("postformmailer.asp", dataCollector, "POST");
}

Wow JT that almost looked like you knew what you were doing!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top