Web Analytics Made Easy -
StatCounter Problem in using Javascript Code delay - CodingForum

Announcement

Collapse
No announcement yet.

Problem in using Javascript Code delay

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problem in using Javascript Code delay

    Let's say I am having a form and i am creating a table and within that table i have two templetes and each template is separated by using <div> tag and each <div> tag is having an id.

    Let' say, i am having a Creditcard form template and it's process showing template. Intiallly when the page is loading, I am showing my Creditcard template and hiding my Process showing template using the following code.

    function loadCredit()
    {
    document.getElementById("divCredit").style.display= "none";
    document.getElementById("divIntermediate").style.display = "block";
    }

    When a user enters information and clicks on authorization button on the Creditcard template then it calls my javascript validation function and checks the validity of information, and once it confims the validity of information it returns true; to go to the clicking code behind and does the add or substract calculation. My validation function is like this:

    funciton validateCC
    {
    //validation javascriot code

    return true;
    }

    What i want to do is, before it returns true and goes to code behind, i want to show the process template and hide the Creditcard template and want to provide some delay before it returns true. i am doing it like this below:

    function
    {
    ///validation code

    document.getElementById("divIntermediate").style.display = "block";
    document.getElementById("divCredit").style.display= "none";
    var millis = 5000;
    date = new Date();
    var curDate = null;
    do
    {
    var curDate = new Date();
    }
    while(curDate-date < millis);

    return true;

    }

    but the problem i am facing is, it goes thorugh the template visibility and invisibility javascript statement but itdoesn't change the template from Creditcard to process showing and it goes to the delay, provides the delay and goes to code behind.

    What i want to do is, before it goes to the delay funciton it should change the template from Creditcard to Process showing and then should go to dealy functionality. I can do it after proving an alert() after the dispaly statements in javascriot..but i don't want to throw an alert() statement...

    I am looking forward for your help..

    Thanks..
Working...
X