< web  portfolio >

Brenda C. Mondragon

< Main Page >


JAVASCRIPT :: Multi-Submit - Multiple Form Submissions


This JavaScript was created to work with a server-side CGI that was able to send only one e-mail at a time. The script worked with several pages set up in frames and would submit one or multiple mails to the CGI depending on which "send to" boxes were checked on the form. The form itself was actually made up of many smaller forms (i.e. formA, formB, etc. seen in the code) on one page, which appeared to be a single form.


The excerpt from one of the scripts of the multiple-script set below shows a few of the main functions, including the function doing the primary action: submitMail(). The other functions demonstrate some parts of the script that worked with other parts to check a cookie that indicated whether the submissions were finished or not.



<SCRIPT LANGUAGE="JavaScript">
<!--

// MULTIPLE-SEND WITH QUICKSEND
// Copyright 1997, Brenda C. Mondragon


var cookieCheck = "null";
var count = "0";

var READY = 1;
var NOTREADY = 0;


function multiSubmit() {
   cookieCheck = setTimeout("checkCookie()", 2000);
} // end of function


function checkCookie() {
   if (parent.getCookie("results") == 1) {
   submitMail(count);
   count++;    
   } // end of if
   
   multiSubmit();
   
} // end of function


function submitMail(count) {

toList = new Array();
toList[0]  = document.formA.tomail;
toList[1]  = document.formB.tomail;
toList[2]  = document.formC.tomail;
toList[3]  = document.formD.tomail;
toList[4]  = document.formE.tomail;
toList[5]  = document.formF.tomail;
toList[6]  = document.formG.tomail;
toList[7]  = document.formH.tomail;
toList[8]  = document.formI.tomail;
toList[9]  = document.formJ.tomail;
toList[10] = document.formK.tomail;


   if (count < toList.length) {
      if (toList[count].checked == 1) {
         document.myForm.To.value = toList[count].value;
         document.myForm.submit();
         parent.setCookie('results', NOTREADY);
      } // end of if (toList)
   } // end of if (count)

   else {
   clearTimeout(cookieCheck);
   top.location.href = "done.html";      
   } // end of else
} // end of function

//-->
</SCRIPT>

Categories:



< Main Page >

This portfolio powered by Blosxom

All content Copyright © 1995 - 2024 Brenda C. Mondragon