Need help with calculations!

# Thread: Need help with calculations!

1. Member
Join Date
Dec 1969
Posts
77

## Need help with calculations!

I have got a counter within my asp page which calculates the the total amount of money spent by the user on the items they have brought, I would like to limit that total to £5, this is a snippet of code that I am using:<BR><BR>&#060;%<BR>countr = countr + rs.fields(2) * request.querystring(countitem)<BR>rs.movenext <BR>loop <BR>%&#062;<BR> &#060;/tr&#062;<BR> &#060;tr&#062;<BR> &#060;td width="185"&#062;&#060;/td&#062;<BR> &#060;td width="172"&#062;&#060;/td&#062;<BR> &#060;td width="112"&#062;&#060;/td&#062;<BR> &#060;td width="40"&#062;&#060;/td&#062;<BR> &#060;/tr&#062;<BR> &#060;tr&#062;<BR> &#060;td width="185"&#062;&#060;/td&#062;<BR> &#060;td width="172"&#062;&#060;/td&#062;<BR> &#060;td width="112"&#062;&#060;b&#062;Grand Total = &#060;/b&#062;&#060;/td&#062;<BR> &#060;td width="40"&#062;&#060;b&#062;£&#060;% =FormatNumber(Countr,2) %&#062; &#060;/b&#062;&#060;/td&#062;<BR> &#060;/tr&#062;<BR>&#060;%<BR>End if <BR>rs.close<BR>%&#062;<BR><BR>Countr is the total amount, can anyone help please I would like to display a message that they are over the limit.<BR><BR>Hope someone can help<BR><BR>Thanks in advance

2. Senior Member
Join Date
Dec 1969
Posts
570

## RE: Need help with calculations!

&#060;%<BR>if Countr&#062;5 then<BR>response.write "Yor are over the limit!!"<BR>end if<BR>%&#062;<BR><BR>learn to use conditionals (http://learnasp.com/learn is a great place)--they do SO much for you

3. Member
Join Date
Dec 1969
Posts
77

That code is great and it works but I do not want the buttons below to appear, I need to force the user back to the page via a button(I know how to do that bit). I have already got an if statement within that page. <BR><BR>This is my code:<BR><BR>&#060;%<BR>If OKFlag = "Yes" then<BR>%&#062;<BR>&#060;% <BR>If Countr&#062;6 then <BR>response.write "You are over the spend limit!!" <BR>%&#062;<BR><BR>&#060;p&#062;&#060;b&#062;Pleas e Note!&#060;/b&#062; &#060;/p&#062;<BR><BR>&#060;p&#062;You will be required to show your Access Card on delivery of your ordered items, the<BR>amount of &#060;b&#062;£&#060;% = FormatNumber(Countr,2) %&#062; &#060;/b&#062;will be deducted from your monthly wages.&#060;/p&#062;<BR>&#060;%<BR>requester = request.querystring()<BR>%&#062;<BR><BR>&#060;form name="form1" method="GET"&#062;<BR> &#060;input type="hidden" name="requester" value="&#060;% = requester %&#062;"&#062;&#060;p&#062;&#060;input type="button"<BR> value="Confirm Order" onclick="Review()"<BR> style="background-color: rgb(0,0,128); color: rgb(255,255,255)"&#062;&#060;input type="button"<BR> value="Changed my mind" onclick="history.go(-1)"<BR> style="background-color: rgb(0,0,128); color: rgb(255,255,255)"&#062;&#060;/p&#062;<BR>&#060;/form&#062;<BR><BR>&#060;p&#062;<BR><BR>&#060;%<BR> else<BR>%&#062;&#060;/p&#062;<BR><BR>&#060;p&#062;&#060;font color="#FF0000"&#062;You must order a pre-order item to be able to use this service,<BR>Please go back and choose again &#060;/p&#062;<BR><BR>&#060;form name="form2" method="GET"&#062;<BR> &#060;p&#062;&#060;input type="Button" value="Go Back" onclick="history.go(-1)"&#062;&#060;/p&#062;<BR>&#060;/form&#062;<BR>&#060;%<BR>end if<BR>end if<BR>%&#062;<BR><BR>where do I put my else if statement?? Sorry, I am new to ASP.<BR><BR>Thank you

4. Helper Guest

## RE: NEED MORE HELP PLEASE

There are a lot of ways to do it but if I understand your question correctly this is the way I would try to do it.<BR><BR>IF Countr &#060; 6 THEN<BR><BR>&#060;form name="form1" method="GET"&#062;<BR>&#060;input type="hidden" name="requester" value="&#060;% = requester %&#062;"&#062;&#060;p&#062;&#060;input type="button"<BR>value="Confirm Order" onclick="Review()"<BR>style="background-color: rgb(0,0,128); color: rgb(255,255,255)"&#062;&#060;input type="button"<BR>value="Changed my mind" onclick="history.go(-1)"<BR>style="background-color: rgb(0,0,128); color: rgb(255,255,255)"&#062;&#060;/p&#062;<BR>&#060;/form&#062;<BR><BR>END IF

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•