November 28th, 2012, 03:51 PM
Help with simple asp query
Hello I really need some help with a simple asp query, I have a cost calculator for a site I am doing where it tells the user how much they have spent over a week on alcohol. The user enters a number in the first box (how much alcohol costs per time) and then they select a number from the second box (the number is how many times a week they consume this alcohol). I have written some code very basic which simply adds this together and brings to the next page and displays ........ 'You have spent .... on alcohol this week' that bit I have done fine. But on that page I want it to use that value (which I have named 'totalalcohol') to setup an If statement where it would display some wording if they have spent between £10-£25 for example:
You have spent £.......(totalalcohol)....... on alcohol this week
With that amount of money you could of bought......("a new ps3 game")
I have about 15 different values going up so I just need some help on setting that part up if anyone could help?
very basic I am a learner still with this.
Thank you for your help
November 28th, 2012, 04:50 PM
something like that
if totalalcohol>0 and totalalcohol<=3 then
response.write "first message"
elseif totalalcohol>3 and totalalcohol<=5 then
response.write "second message"
elseif totalalcohol>5 and totalalcohol<=10 then
response.write "third message"
elseif totalalcohol>11 then
response.write "forth message"
if you found this post is useful click Give Rep button (bottom side on this reply ) and agree
November 28th, 2012, 05:03 PM
Oh that's great thank you very much for your quick reply. Do you think this will work? I can't test it until I am at work tomorrow when I can upload the web page on the testing server.
I had done something similar today at work but it didn't work, kept erroring on the '>' or '<' but I was using the numbers with quotes around e.g. "10" would this be why I was having the problem?
Thanks so much, do you know of any asp resources which would be helpful to me in learning? I am keen to get a grip of this as I am in a new job at the moment and want to do well
November 29th, 2012, 08:08 AM
you have totalalcohol as result of calculation an that page, so it is a number not string
if totalalcohol>0 then
if totalalcohol>"0" then
in first case you compare number to number on second number to string