How to keep the data in the form fields visible after the submit button is pressed

K

karenmiddleol

I have the following form the user enters the From and to period and
presses the Submit button and the form fields are cleared once the
submit button is pressed.

Is there a way I can keep the Form fields visible and not cleared.

Also when I display the message I want the original form cleared in a
different version of this page how can I clear the form completely when
I display the data entered from the Response statements I do not want
the form fields or the submit button visible anymore just the response
statements.

Your help is deeply appreciated.

Thanks
Karen

<html>
From Period : <input type="text" name="FromPeriod"><br>
To Period : <input type="text" name="ToPeriod">
<input type="submit" value="Submit" action = "Go">
</form>
<%
'// Check the first field only (assumes it is required)
If Request.Form("FromPeriod") <> "" Then
Response.Write "From: " & Request.Form("FromPeriod") & "<br>"
Response.Write "To: " & Request.Form("ToPeriod")
End If
%>
</body>
 
R

Ray Costanzo [MVP]

The easy way to redisplay form values is to just do <input name="x"
value="<%=Request.Form("x")%>" />

<%
Dim bShowForm : bShowForm = True

''put your code here that would decide if the form should be shown or not.
''If it shouldn't be, set bShowForm to false.

'' What's action="go"?
%>

<html>
<body>
From Period : <input type="text" name="FromPeriod"
value="<%=Server.HtmlEncode(Request.Form("FromPeriod"))%>"><br>
To Period : <input type="text" name="ToPeriod"
value="<%=Server.HtmlEncode(Request.Form("ToPeriod"))%>">>
<input type="submit" value="Submit" action = "Go">
</form>
<% End If %>
<%
'// Check the first field only (assumes it is required)
If Request.Form("FromPeriod") <> "" Then
Response.Write "From: " & Request.Form("FromPeriod") & "<br>"
Response.Write "To: " & Request.Form("ToPeriod")
End If
%>
</body>

Ray at home
 
K

karenmiddleol

Hi Ray

Sorry, another clarification when I set
Dim bShowForm : bShowForm = False

even the form fields disappear for the first time.

Can I dynamically have a button when the user presses it the form
fields can be cleared of
the page and when it is pressed again the form fields appears again.

Thanks
Karen
 
R

Ray Costanzo [MVP]

Sure, maybe something like.
<%
Dim bShowForm
bShowForm = CBool(Request.Querystring("showform"))
%>


<a href="thispage.asp?showform=<%=Abs(CInt(Not bShowForm))%>">click</a>

<% If bShowForm Then %>
put form here
<% End If %>


Or just do it with javascript.

Ray at work

p.s. Not posted to
microsoft.public.inetserver.asp,microsoft.public.inetserver.asp.db,microsoft.public.inetserver.asp.faq
http://www.aspfaq.com/5004
 

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

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top