Javascript function help

by "Tom Keatley" <tom(at)piedpiper.com.au>

 Date:  Tue, 15 Feb 2000 23:09:14 +0800
 To:  <hwg-languages(at)hwg.org>
 References:  net
  todo: View Thread, Original
Hi all...

I am comparitively new to Javascript and have the function code (below) used
to give me the total value ordered on a form by indexing "TIT" (a series of
textboxes with value set to 0 TIT_001, TIT 002 etc). I also need to get a
COUNT of items on the form using the same parameters of "TIT" but only items
>= 1.

so that a client could have ordered 10 items comprising 100 units say

I have been "playing" with this on and off for DAYS and cant seem to get it
right

If someone could assist with the appropriate code either in this function or
a separate on I would appreciate it ...

TIA

Tom Keatley


===============================================
function compute(myform) {

     var runningTotal = 0;

     // Loop through all the field elements and if add their values to
     // the running total variable if their name starts with "TIT".
     for(var i=0;i<myform.elements.length;i++) {
         if(myform.elements[i].name.indexOf("TIT") == 0) {
             runningTotal += parseInt(myform.elements[i].value);
        }
     }
     myform.grndtotal.value = runningTotal;
     }
=================================================

HWG: hwg-languages mailing list archives, maintained by Webmasters @ IWA

This page is part of a preserved archive of archives.hwg.org. The site is no longer active and its content is not maintained. For enquiries about this archive, write to archive(at)iwanet.org.