adding values from a submitted form

S

sean

HI There,

I am trying to total the value of some form fields I am referecing the form
field with an inner loop, I am having a little trouble because the amount of
fields returned is always different, how can I roll-up the total of the form
fields (request.form("subtotal_"& i)) to get one final figure?

Sean - Thanks in advance for your answer


for i = 1 to Request.Form.Count
if request.form("quantity_"& i) <> "" AND request.form("quantity_"& i) <>
"0" then

!-- inner loop

dim j
dim thetotalof
for j = 1 to request.form("subtotal_"& i).count
thetotalof = request.form("subtotal_"& i)

response.Write thetotalof
next

!-- finish inner loop


thecounter = thecounter + 1
response.Write "<tr><td>" & trim(stripQuotes(request.form("productid_"&
i))) & "<input type=hidden name=productid_" &

thecounter & " value='" & trim(stripQuotes(request.form("productid_"& i))) &
"'></td><td>" &

trim(stripQuotes(request.form("quantity_"& i))) & "<input type='hidden'
name=quantity_" & thecounter & " value='" &

trim(stripQuotes(request.form("quantity_"& i))) & "'></td><td>" &
Application ("defaultcurrency") & " " &

FormatNumberVal(trim(stripQuotes(request.form("subtotal_"& i)))) & "<input
type='hidden' name=subtotal_" & thecounter & "

value='" & trim(stripQuotes(request.form("subtotal_"& i))) & "'></td></tr>"
end if
next
 
S

Slim

sean said:
HI There,

I am trying to total the value of some form fields I am referecing the form
field with an inner loop, I am having a little trouble because the amount of
fields returned is always different, how can I roll-up the total of the form
fields (request.form("subtotal_"& i)) to get one final figure?

Sean - Thanks in advance for your answer


i thing this may be what you want
dim quantityTotal
for each thing in Request.Form
if InStr(1,thing,"quantity") > 0 then
if IsNumeric(Request.Form(thing)) then
quantityTotal = quantityTotal + Request.Form(thing)
end if
end if
next


for i = 1 to Request.Form.Count
if request.form("quantity_"& i) <> "" AND request.form("quantity_"& i)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,156
Messages
2,570,878
Members
47,408
Latest member
AlenaRay88

Latest Threads

Top