SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Inserting a Delay Between Multiple Form Submissions

    I am working on a web page that interacts with Filemaker Pro. Specifically, the page allows you to update multiple records at once. To accomplish this, a separate form is needed per displayed record.

    Anyway, in my testing it appears that Filemaker Pro can't handle multiple submissions unless I insert a small delay after each individual submission. The JS code for the form submissions appears below:
    Code:
    function submitForms()
    {
    	var numberOfForms = document.forms.length;
    	for (i = 0; i < numberOfForms; i++)
    	{
    		document.forms[i].submit();
    	}
    }
    I am trying to do this: submit form 0, delay, submit form 1, delay, etc. However, after playing with the setTimeout function, I can't seem to make this work. Any ideas?

    Thanks,


    Sean

  2. #2
    SitePoint Zealot jonsteele's Avatar
    Join Date
    Jan 2001
    Location
    Toronto
    Posts
    106
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    First I beleive you will need to post the forms to new windows, to keep the main browser window at the page with all the forms.

    Second what you are looking for is the setInterval function.

    Try the following. 2000 designates a two minute delay. You will need to add init() to the body tags onload attribute.


    Code:
    i = 0;
     
    function dosubmit(){
       if(i < document.forms.length){
    	  document.forms[i].target = "_blank";
    	  document.forms[i].submit();
       }
       i++;
    }
     
    function init(){
       setInterval("dosubmit()",2000);
    }
    ...
    ...
    ...
    <body onload="init()">

  3. #3
    SitePoint Member
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the reply, Jon.

    FYI, to keep the browser on the same page until all of the forms have been submitted, I created a small 1x1 iframe (one for each form) that the browser bounces to after submitting an individual form. I can't take the credit for the trick, but it works well.

    Also, instead of putting your init() function in an onLoad handler, I placed it in a button's onClick handler, since a user is going to make changes to the displayed records.

    Anyway, I really appreciate your help. Your suggested changes have definitely helped. FWIW, I was having trouble updating records in IE 6. They would only update intermittently.

    Sean


Bookmarks

Posting Permissions

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