Problem With Request.Form

W

Wayne Wengert

I am trying to use Request.Form to differentiate between when a page
containing a form is first loaded and when it is reloaded as a result of the
user clicking on the Submit button. Things are not working as expected. Some
snippets of my code are:

fSubmit = Request.Form("Submit1") = "Process"
Response.Write("Submit1 " & Request.Form("Submit1") & "<br>")
Response.Write("fSubmit: " & fSubmit & "<br>")
......

<form <%=Request.Servervariables("URL")%> method=post Name="cktlogin">
<b>Authorization Code: </b><Input Type="PASSWORD" Name="pw" Size="15"
Maxlength="15" Value="">
<p>
<INPUT NAME="Submit1" TYPE=Submit Value="Process">
</form>

I expected that the value of Request.Form("Submit1") would contain
"Process" only after the user clicks on the Submit button but it is set to
that value as soon as the page loads the first time?

What is the correct way to determine if the Submit button was clicked?

TIA

Wayne
 
A

Alex Goodey

if Request.Form("Submit1") = "Process" then
CODE WHEN FORM IS SUBMITTED
end if

<form...........>

FORM STUFF

</form>
 
W

Wayne Wengert

Alex;

Thanks for the response but that is basically what I am doing. The statement
fSubmit = Request.Form("Submit1") = "Process"

should set fSubmit to False unless the button has been clicked (I thouight!)

When I load the page the Response.Write statements show that
Request.Form("Submit1") has the value "Process" before the button has been
clicked?

Wayne
 
A

Aaron Bertrand [MVP]

When I load the page the Response.Write statements show that
Request.Form("Submit1") has the value "Process" before the button has been
clicked?

I'm totally confused. How do you have a request.form collection, if you
haven't submitted the form? In other words, if the button *hasn't* been
clicked, then the form hasn't even been submitted.
 
W

Wayne Wengert

I am equally confused for the same reason! I have never seen anything like
this. I expected the Request.Form values to be populated only after I
pressed the submit key. That is not happening?

Wayne
 
W

Wayne Wengert

Learned something - I cleared all cookies and cached pages and that seemed
to let things work as expected. I really don't understand why that affects
things but...

I'll keep experimenting!

Wayne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,163
Latest member
Sasha15427
Top