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 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Aug 2007
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    putting in handle enter code

    I have the following code in my system. the start is the main focus. I have an action where when a button 'Confirm' is pressed, it enables the preceeding action. I need to insert handle enter code somewhere so it detects when enter is pressed instead of the 'confirm' button. Can anyone give me any guide on the code i could put in?

    Thanks

    Matt



    if request.form("submit") = "CONFIRM" then
    xuid=request.form("uid")
    set con= Server.CreateObject("ADODB.Connection")
    con.Open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("/database/urlnet.mdb"))
    set rs8= Server.CreateObject("ADODB.Recordset")
    rs8.CursorType = adOpenStatic
    sql="select * from urlnet where combination='" & trim(xuid) & "'"
    rs8.open sql,con
    if rs8.eof then
    Response.write("<script language=Javascript> alert('Invalid Combination');")
    Response.write("</script>")
    else
    rs8.movefirst
    xurl="http://" & rs8("url")
    Response.write("<script language=Javascript> xopen('" & xurl & "');")
    Response.write("</script>")
    end if
    end if
    %>

  • #2
    Senior Coder
    Join Date
    Dec 2002
    Location
    Arlington, Texas USA
    Posts
    1,072
    Thanks
    4
    Thanked 8 Times in 8 Posts
    Most error handling code should be a combination of both Client side validation and server side code to handle the errors.

    For the client side add an onclick event to the button which calls a javascript function. This function can be as easy as an alert that makes the statement that the confiirmation must happen first. You could also disable the button at page load and only enable it through the onClick event that would be called when the confirmation is selected.

    Then on the server side, look for the confirmation, if it is a checkbox was it selected? If so allow the code to continue to process if not send the user a message using response.write that tells them that they did not confirm, at the same time: if it is a seperate page and not a postback, after the message include a button which will take them back 1 page in the history so that they can confirm; if it is a postback, display the filled in form allowing the user to confirm end then resubmit.


  •  

    Posting Permissions

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