Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Capturing the submit button value 1

Status
Not open for further replies.

Jorgandr

Programmer
May 10, 2002
58
0
0
US
I have some code:

if not isempty(Request.form("Submit")) then
do code
end if

This works if the user clicks on the submit button but not if they hit the enter key.. Is there a way around this so that it will always run that code in the if statement if they click on the submit or hit the enter key? Thank you.
 
Hi...
Can you describe a little more ?
I know that you have a form with a submit button and when you press that button, and your form posts to an asp file, everything works fine.
but when you press enter in your form, you have a problem.
so if you just send your form and you asp which your form posts to here to see...

----
TNX.
E.T.
 
if you use the regular Submit control in the form, you can either click the submit button or hit the enter key. You can use
If request("submit") = submitButtonValue then
do something
end if

not sure whether it is the answer you need.

Longmatch
 
Here's an easy test of the problem. If I were to write a simple piece of coding:

<html>
<head>
</head>
<body>
<form method=&quot;POST&quot; name=&quot;test&quot; action=&quot;../testpage.asp&quot;>
<table>
<tr>
<td>
<input type=&quot;Text&quot; name=&quot;Test&quot;>
</td>
<td>
<input type=&quot;Submit&quot; name=&quot;Submit&quot; value=&quot;Submit&quot;>
</td>
</tr>
</table>
<%response.write Request.form(&quot;Submit&quot;)%>
</form>
</body>
</html>

Here are the 3 scenarios and the value that is written on the page after the submit is done

1. Clicking on it ---> Writes &quot;Submit&quot; on the page
2. Tabbing so the Submit ---> Writes &quot;Submit&quot; on the page
is focused and then
hitting enter
3. Hitting the enter while --> Writes nothing on the page
in the text box

Because of that my coding that includes

if not isempty(Request.form(&quot;Submit&quot;)) then
code
end if

will only work if the first 2 scenarios are done but not if the 3rd one happens. obviously I want it to happen for all 3. Any suggestions? Thank you.
 
What I do is add a hidden form field and check it -- it will be submitted no matter how the user submits the form.
Code:
<input type=&quot;hidden&quot; name=&quot;UserSubmit&quot; value=&quot;1&quot;>
 
you just want to test if the page has been submitted?

try :
Code:
if Request.TotalBytes > 0 then
  'blabla
end if

Totalbytes is the length of stuff been submitted (so if nothing has been submitted, it will be 0).

That help?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top