#1
  1. No Profile Picture
    Registered User
    ASP Explorer (0 - 99 posts)

    Join Date
    Nov 2012
    Posts
    2
    Rep Power
    0

    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
    Rach
  2. #2
  3. Contributing User
    ASP Skiller (1500 - 1999 posts)

    Join Date
    Mar 2005
    Location
    Columbus, OH
    Posts
    1,600
    Rep Power
    278
    something like that

    Code:
    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"
    END IF
    GK
    __________________________________________________ _____
    if you found this post is useful click Give Rep button (bottom side on this reply ) and agree
  4. #3
  5. No Profile Picture
    Registered User
    ASP Explorer (0 - 99 posts)

    Join Date
    Nov 2012
    Posts
    2
    Rep Power
    0
    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
    Cheers

    Rach x
  6. #4
  7. Contributing User
    ASP Skiller (1500 - 1999 posts)

    Join Date
    Mar 2005
    Location
    Columbus, OH
    Posts
    1,600
    Rep Power
    278
    you have totalalcohol as result of calculation an that page, so it is a number not string
    if totalalcohol>0 then
    not equal
    if totalalcohol>"0" then
    in first case you compare number to number on second number to string

Similar Threads

  1. Simple If less than query...
    By designsonline in forum ASP Development
    Replies: 5
    Last Post: May 3rd, 2010, 05:20 PM
  2. Simple Query Analyzer Query question
    By wesruber in forum Microsoft SQL Server
    Replies: 2
    Last Post: June 26th, 2008, 11:16 AM
  3. Simple SQL query
    By tommot82 in forum SQL Development
    Replies: 1
    Last Post: August 27th, 2006, 10:05 PM
  4. Simple SQL query help
    By imbrod in forum ASP Development
    Replies: 6
    Last Post: February 15th, 2006, 06:58 AM
  5. simple query
    By mickyc1 in forum ASP Development
    Replies: 9
    Last Post: April 4th, 2005, 09:31 AM

IMN logo majestic logo threadwatch logo seochat tools logo