473,396 Members | 2,059 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

adding values from a submitted form

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("sub total_"& i)))) & "<input
type='hidden' name=subtotal_" & thecounter & "

value='" & trim(stripQuotes(request.form("subtotal_"& i))) & "'></td></tr>"
end if
next
Jul 19 '05 #1
1 1674

"sean" <se**********@shopsmart.com.au> wrote in message
news:#7**************@TK2MSFTNGP10.phx.gbl...
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) <> "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("sub total_"& i)))) & "<input
type='hidden' name=subtotal_" & thecounter & "

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

Jul 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Ken | last post by:
How can I reset the initial form variables that are set with session statements when clicking on a button? I tried this but the function was not called: <?PHP function reset_form($none) {...
6
by: Ben Hallert | last post by:
Hi guys, I'm trying to figure out what bone headed mistake I made on something I put together. I've got a form (named 'context') that has a variable number of select-multiple inputs on it. ...
1
by: Richard Dixson | last post by:
Under ASP.NET (C#) I want to create a page that people can use to submit questions. This page will consist of a table with several rows of information, like: Name: Bill Smith Job title:...
2
by: Richard Dixson | last post by:
Under ASP.NET (C#) I want to create a page that people can use to submit questions. This page will consist of a table with several rows of information, like: Name: Bill Smith Job title:...
5
by: johnny | last post by:
hi all, I wonder if I could do the following task in PHP before searching for javascript which I prefer not to have in my code: I have a form to create new tables in a database and, since I...
2
by: jackson2005 | last post by:
OK, I need to do three different things. On the ONLOAD event I would like a popup box to open. In this popup box I need two text boxes. One for the UserName and one for the BillingTo name. ...
6
by: Ian Davies | last post by:
Hi me again, sorry to be a pain. Ive been struggling with this one all day. Hope you can understand whats happening. First my script is below. Have a look and I'll explain at the bottom what it...
9
by: Kevin Blount | last post by:
Here's the code I tried, and found it failed... <form runat="server" method="post" name="CreditCardForm" id="CreditCardForm"> <% foreach (object item in Request.Form) { if...
2
by: AndyW2387 | last post by:
Hi I'm quite a newbie and have been struggling with sessions (!) What I'm trying to do is to add submitted values from a textfield (or ID number) to an array which is in a $_SESSION. ( It's for a...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.