View Full Version : putting in handle enter code

08-11-2007, 10:40 AM
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 :)


if request.form("submit") = "CONFIRM" then
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');")
xurl="http://" & rs8("url")
Response.write("<script language=Javascript> xopen('" & xurl & "');")
end if
end if

08-11-2007, 04:05 PM
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.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum