Passing Form Name

Results 1 to 2 of 2

Thread: Passing Form Name

  1. #1
    Join Date
    Dec 1969

    Default Passing Form Name

    This is what I have right now for my sum function. It sums all the rows (each in a differant form) and returns the results to the appropriate text boxes. The array JSArray contains the name of the current form. This line causes errors...<BR><BR>Mon=document.JSArray[i].Mon.value+Mon<BR><BR>as it looks for the form JSArray instead of the proper variable. How do I make it use the variable? Here is the whole function incase you need to see it / want to steal it.<BR> <BR>function sumitems()<BR>{<BR>var Mon=0, Tue=0, Wed=0, Thur=0, Fri=0, Sat=0, Sun=0<BR> <BR> for (i=0; i&#060;JSArray.length; i++)<BR> {<BR> Mon=document.JSArray[i].Mon.value+Mon<BR> }<BR> document.totals.MonSum.value=Mon<BR> document.totals.TueSum.value=Tue<BR> document.totals.WedSum.value=Wed<BR> document.totals.ThurSum.value=Thur<BR> document.totals.FriSum.value=Fri<BR> document.totals.SatSum.value=Sat<BR> document.totals.SunSum.value=Sun<BR> document.totals.GrandTotal.value=Mon+Tue+Wed+Thur+ Fri+Sat+Sun<BR> }<BR>&#060;/script&#062;

  2. #2
    Join Date
    Dec 1969

    Default RE: Passing Form Name

    Mon=document.forms[ JSArray[i] ].Mon.value+Mon<BR><BR>As with most any other browser element, the document.forms array can be indexed by *either* the ordinal number of the form or by the name of the form. <BR><BR>Now...WHY do you have more than one form on your page???<BR><BR>

Posting Permissions

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