If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > Problem with Enter Key to submit form

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-13-04, 22:42
SandyLeang SandyLeang is offline
Registered User
 
Join Date: Jan 2004
Location: Phnom Penh
Posts: 9
Problem with Enter Key to submit form

Dear all,

I have a problem with enter key to submit form. For example,

I have one textfiled and one submit button for my search form with method "get".

When i filled in the keywork into the textfiled and press "Enter Key" the value passing in IE address bar is just only http://localhost/search.asp?txt_keyword=mekong

so that does not work if i use the below code to fire my search event,
.........................................
if request("submit") <> "" then
.........................................
.........................................

That is different, and it work if i click on submit button. IE address bar show, http://localhost/search.asp?txt_keyw...&Submit=Search

But i think that most users will press "Enter Key" are much more convinient, right?

Anyone could help me on this issue?

Thanks in advance.
Attached Files
File Type: zip submit_enter.zip (18.5 KB, 22 views)
Reply With Quote
  #2 (permalink)  
Old 01-13-04, 22:48
rokslide rokslide is offline
Registered User
 
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
Why are you checking for the clicking of the "Search" button?

Instead search for the presence of a search criteria (eg. your keyword).

The advantage with this is that you can then send url's to people to show the search results directly, rather then forcing the user to have to go to the search page and enter the keyword themselves.

So instead of

Code:
if request("submit") <> "" then
use

Code:
if request("txt_keyword") <> "" then
Reply With Quote
  #3 (permalink)  
Old 01-13-04, 23:07
SandyLeang SandyLeang is offline
Registered User
 
Join Date: Jan 2004
Location: Phnom Penh
Posts: 9
Thanks for your help.

So the seach button, pass its value only when user click on it ? no customize on the form that could do that (pess the key Enter and also pass the value of search button)?
Reply With Quote
  #4 (permalink)  
Old 01-13-04, 23:16
rokslide rokslide is offline
Registered User
 
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
Yes. The search button will only pass a value if it is clicked.

You could create some javascript catch the submit via the Enter key and then pass a value to the search results page, but really it is more trouble then it is worth IMO.

Just check for a search criteria (eg. a keyword) and forget the rest would be my advice.
Reply With Quote
  #5 (permalink)  
Old 01-13-04, 23:45
gyuan gyuan is offline
Registered User
 
Join Date: Dec 2003
Posts: 454
Ignore the difference between pressing Enter key and clicking the button "Submit". Like rokslide said, you can not use Request("Submit") <> "" to make a decision that the sumbit button is clicked. I give you an example. On the form, there are two buttons, "Save" and "Preview", which both submit the form. Since the both buttons have their values, you can not know which button is clicked base on Request("Submit") <> "". You need to use another way to check it.
Reply With Quote
  #6 (permalink)  
Old 01-13-04, 23:56
rokslide rokslide is offline
Registered User
 
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
That's not quite right gyuan (okie, so it is right, but it's a little misleading)

Quote:
On the form, there are two buttons, "Save" and "Preview", which both submit the form. Since the both buttons have their values, you can not know which button is clicked base on Request("Submit") <> "".
Each button with have a different id eg btnSave and btnPreview and you would have to request those values to determine what was pressed eg...

[code]
If Request("btnSave") = "Save" then myAction="Save"
If Request("btnPreview") = "preview" then myAction="Preview"
[code]

The fact that they both submit should not confuse the issue.

My statement still stands though. If you arrive on the page with a search criteria, then do a search (weather the Search button was clicked or not).
Reply With Quote
  #7 (permalink)  
Old 01-14-04, 02:44
SandyLeang SandyLeang is offline
Registered User
 
Join Date: Jan 2004
Location: Phnom Penh
Posts: 9
Thanks to Rockslide and Gyuan!!! for your help!!!

Cheers!!!
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On