Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Mar 2006
    Posts
    38
    Thanks
    0
    Thanked 0 Times in 0 Posts

    help slowing a function

    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(){
    sendform();
    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.

  • #2
    New Coder
    Join Date
    Jan 2006
    Location
    Cairo, Egypt
    Posts
    30
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi rulian, how are you ?
    sendform();
    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.
    SORRY FOR MY POOR ENGLISH
    Khaled Mahmoud
    Web, Flash, Games developer.
    JavaScript reference VBScript reference ASP reference

  • #3
    Senior Coder
    Join Date
    Jul 2005
    Location
    New York, NY
    Posts
    1,084
    Thanks
    4
    Thanked 19 Times in 19 Posts
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •