Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Apr 2006
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    date calculations and display..

    I'm creating a dvd hire webby for uni and i'm stuck on getting the return date to calculate aand was wondering if anyone could help me.. here is my code:

    <%
    Dim IDKEY, CUSTID, HireLength, DateAdd, days, Price, Dateofreturn

    IDKEY=Request.form("IDKEY")

    SQL_CUSTID = "SELECT * FROM cust WHERE CUSTID= 'Surname'"
    SQL_CUSTID = CUSTID

    HireLength= ChkString(Request.form("HireLength"))
    days = CStr(HireLength)

    response.write "Debug: HireLength = " & HireLength & "!"
    response.flush

    if Hirelength = "4" THEN
    Price = "£4.00"
    Dateofreturn = (DateAdd("d",8,date()))
    End if

    if Hirelength = "7" THEN
    Price = "£6.00"
    Dateofreturn = (DateAdd("d",11,date()))
    End if

    %>

    <table border="0" cellpadding="4" cellspacing="2" align="center"><br>
    <tr><td><b>Product ID:</b></td><td><%response.write(request.querystring("IDKEY"))%></td>
    <td><b>Film:</b></td><td><%response.write(request.querystring("Film"))%></td>
    <td><b>Length of Hire:</b></td><td><%response.write(request.querystring("HireLength") & "&nbsp;days")%></td></tr>
    <tr><td><b>Price:</b></td><td><%response.write(Price)%></td>
    <td><b>Hire Date:</b></td><td><%=Date()%></td>
    <td><b>Return Date:</b></td><td><%response.write(Dateofreturn)%></td></tr>

    </table>


    <%


    Set RS = Nothing

    objConn.Close
    Set objConn = Nothing
    %>

  • #2
    New to the CF scene
    Join Date
    Apr 2006
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    the Price and Dateofreutrn should be displaying but they are not... the Hirelength value is cleary posted as 7, so with if statment Price should = 6 and Dateofreutrn should equal date +11 days.. but they aren't displaying, have made a simple syntax error in the IF statment?

  • #3
    Senior Coder
    Join Date
    Nov 2002
    Location
    North-East, UK
    Posts
    1,265
    Thanks
    0
    Thanked 0 Times in 0 Posts
    DateAdd is a functions. Don't Dim it.

    Also you are mixing Request.Form and Request.QueryString in your code.

  • #4
    New to the CF scene
    Join Date
    Apr 2006
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    its definatly something to do with my if then statment:

    HireLength=CStr(Request.querystring("HireLength"))

    if HireLength = "4" THEN
    Price = "£4.00"
    Dateofreturn = (DateAdd("d",8,date()))
    End if

    if HireLength = "7" THEN
    Price = "£6.00"
    Dateofreturn = (DateAdd("d",11,date()))
    Else
    Price = "Invalid"
    Dateofreturn = "Invalid"
    end if
    %>
    <table border="0" cellpadding="4" cellspacing="2" align="center"><br>
    <tr><td><b>Product ID:</b></td><td><%response.write(request.querystring("IDKEY"))%></td>
    <td><b>Film:</b></td><td><%response.write(request.querystring("Film"))%></td>
    <td><b>Length of Hire:</b></td><td><%response.write(request.querystring("HireLength") & "&nbsp;days")%></td></tr>
    <tr><td><b>Price:</b></td><td><%response.write(Price)%></td>
    <td><b>Hire Date:</b></td><td><%=Date()%></td>
    <td><b>Return Date:</b></td><td><%response.write(Dateofreturn)%></td></tr>

    </table>

    Price/Date of return are currently displaying as invalid..

    They shouldn't HireLength is passed through the url as equal to 4 or 7 so price and dateofhire should be equal to the conidtion i have set..

  • #5
    Senior Coder
    Join Date
    Nov 2002
    Location
    North-East, UK
    Posts
    1,265
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Your code is fine. Fix the two points I mentioned.


  •  

    Posting Permissions

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