View Full Version : help slowing a function

06-06-2006, 02:49 PM
I have two frames on my page conviniently named left and right.

left frame has a form which it submits to the right frame.
the right frame is suppose to proccess the form and return a variable of good or bad.

everything works as it should, i get the variable back, problem is the javascript doesnt wait for the page to actually loado n the right frame and simply returns the default value immediately.

here is an sample

function getVar(){
var myvar=window.rightframe.myvarible;
return myvar;

function proccess(){
var returned=getVar();

if (returned == 'myvalue') godothis();
else godothat();


function sendform(){
this function sends the form out to frame right

the submit button submits the form and OnSubmit="proccess()";

how can I delay the execution of getVar()?
I know I can use setTimeout but the returned will equal a number, not the value i need to compare.

06-21-2006, 05:43 PM
Hi rulian, how are you ?

var returned=getVar();
The problem is the second line executed while sendform function is in proccessing and don't wait for ending processing.
The solution is putting the second line in the end of sendform function.

06-21-2006, 05:54 PM
Delaying isn't the issue.

You have no idea how long it will take for that page to reload. Slow internet, slow connection, these will ruin whatever timing you put it.

Instead, you need to form to call back to the original frame when it finished loading, probably through setting document.onload in a script on the form or onload property in the body tag of the form.