Thanks for the help guys!! Your time is appreciated.
> If you are referring to a dynamic table in a browser page where the user may
> add new rows, you'll have to perform the arithmetic in client script. The
> Request object is a server side object.
>
> However, if you want to present data from your database and include the
> total (of all the rows for a column), use SQL to obtain the total (in a
> separate query), or add the values to a total while populating the array (as
> in example - I assume you want to calculate the grand total of donations -
> i.e. logically Sum(rs("product_qty") * rs("product_donation_amt")):
>
> currDonationsTot = 0
> Do While Not rs.EOF
> sAllProd = sAllProd & "<tr>" & vbCRLF
> sAllProd = sAllProd & "<td align='left' valign='middle'><font
> face='arial' size='2' value='"
> & rs("product_id") & "'>" & rs("product_description") &
> "</font></td>" & vbCRLF
> sAllProd = sAllProd & "<td align='center' valign='middle' value='"
> & rs("product_qty") & "'>" & rs("product_qty") & "</td>" &
> vbCRLF
> currDonationThis = rs("product_qty") * rs("product_donation_amt")
> currDonationTotal = currDonationTotal + currDonationThis
> sAllProd = sAllProd & "<td align='right' valign='middle'
> name='donation_amt'>"
> & formatnumber(currDonationThis, 2) & "<br><br></td>" &
> vbCRLF
> sAllProd = sAllProd & "</tr>" & vbCRLF
>
> '***** Set variable to a comma delimited string for using in the updated
> stored procedure above. *****
> sCustAllProducts = strcustAllProducts & rs("product_id") & ", "
> rs.MoveNext
> Loop
>
> sAllProd = sAllProd & "<tr>" & vbCRLF
> sAllProd = sAllProd
> & "<td align='left' valign='middle'><font face='arial'
> size='2'>Total:</font></td>"
> & vbCRLF
> sAllProd = sAllProd & "<td> </td>" & vbCRLF
> sAllProd = sAllProd & "<td align='right' valign='middle'>"
> & FormatNumber(currDonationTotal, 2) & "</font></td>" &
> vbCRLF
> sAllProd = sAllProd & "</tr>" & vbCRLF
> sAllProd = sAllProd & "</table>" & vbCRLF
> '***** Remove the comma at the end of the last record. *****
> strcustAllProducts = left(strcustAllProducts, len(strcustAllProducts) - 2) &
> " "
> End If
> rs.Close
> Set rs = Nothing
>
>
> HTH,
> Tore.
>
>
> ----- Original Message -----
> From: "msavoy" <[EMAIL PROTECTED]>
> To: "ActiveServerPages" <[EMAIL PROTECTED]>
> Sent: Monday, November 04, 2002 9:15 PM
> Subject: Totaling a column in a table
>
>
> > I am trying to create a total within a table that I am creating on the
> > fly, whereby an infinite amount of records can be added to this table.
> > Any suggestions or direction would be appreciated. I had tried the SUM
> > function in the total row but to no avail.
> >
> > Here is the code I have developed in order to create the table:
> >
> > '***** Setup the variable to ensure empty before populating. *****
> > strcustAllProducts = ""
> > '***** Build the Apologetic products table associated with this customer
> > and where user can add or delete product. *****
> > If Not rs.EOF Then
> > strfname = trim(rs("customer_fname"))
> > strlname = trim(rs("customer_lname"))
> > strAllProducts_table = "<TABLE width='575' align='left' border='1'
> cellpadding='2' cellspacing='0'>"
> > strAllProducts_table = strAllProducts_table & "<tr>" & vbCRLF
> > strAllProducts_table = strAllProducts_table & "<th><font face='arial'
> size='2'>Product:</font></th>" & vbCRLF
> > strAllProducts_table = strAllProducts_table & "<th><font face='arial'
> size='2'>Qty.:</font></th>" & vbCRLF
> > strAllProducts_table = strAllProducts_table & "<th><font face='arial'
> size='2'>Suggested Donation Amt.:</font></th>"
> > & vbCRLF
> > strAllProducts_table = strAllProducts_table & "</tr>" & vbCRLF
> >
> > '***** Setup the variable to ensure empty before populating
> > strcustAllProducts = ""
> > '***** Start loop for all products associated with the customer_id. *****
> > Do While Not rs.EOF
> > strAllProducts_table = strAllProducts_table & "<tr>" & vbCRLF
> > strAllProducts_table = strAllProducts_table & "<td align='left'
> valign='middle'><font face='arial' size='2' value='" & rs("product_id") &
> "'>" &
> > rs("product_description") & "</font></td>" & vbCRLF
> > strAllProducts_table = strAllProducts_table & "<td align='center'
> valign='middle' value='" & rs("product_qty") & "'>" & rs("product_qty") &
> "</td>"
> > & vbCRLF
> > strAllProducts_table = strAllProducts_table & "<td align='right'
> valign='middle' name='donation_amt'>" &
> > formatnumber(rs("product_qty") * rs("product_donation_amt"), 2) &
> "<br><br></td>" &
> > vbCRLF
> > strAllProducts_table = strAllProducts_table & "</tr>" & vbCRLF
> >
> > '***** Set variable to a comma delimited string for using in the updated
> > stored procedure above. *****
> > strcustAllProducts = strcustAllProducts & rs("product_id") & ", "
> > rs.MoveNext
> > Loop
> > strAllProducts_table = strAllProducts_table & "<tr>" & vbCRLF
> > strAllProducts_table = strAllProducts_table & "<td align='left'
> valign='middle'><font face='arial' size='2'>Total:</font></td>" & vbCRLF
> > strAllProducts_table = strAllProducts_table & "<td> </td>" & vbCRLF
> > strAllProducts_table = strAllProducts_table & "<td align='right'
> valign='middle'>" &
> > sum(Request.Form("donation_amt")) & "</font></td>" & vbCRLF
> > strAllProducts_table = strAllProducts_table & "</tr>" & vbCRLF
> > strAllProducts_table = strAllProducts_table & "</table>" & vbCRLF
> > '***** Remove the comma at the end of the last record. *****
> > strcustAllProducts = left(strcustAllProducts, len(strcustAllProducts) -
> > 2) & " "
> > End If
> > rs.Close
> >
> >
> > ---
> > You are currently subscribed to activeserverpages as:
> [EMAIL PROTECTED]
> > To unsubscribe send a blank email to
> %%email.unsub%%
> >
---
You are currently subscribed to activeserverpages as: [email protected]
To unsubscribe send a blank email to [EMAIL PROTECTED]