Javascript Function Question

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

 Date:  Wed, 16 Feb 2000 12:06:48 +0800
 To:  <hwg-basics(at)hwg.org>
 References:  hotmail
  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;
     }
=================================================

HTML: hwg-basics mailing list archives, maintained by Webmasters @ IWA