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

Discussion in 'ASP General' started by karenmiddleol@yahoo.com, Oct 1, 2005.

  1. Guest

    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>
    <body>
    <form method="post" action="pForm.asp">
    >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>
     
    , Oct 1, 2005
    #1
    1. Advertising

  2. 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>
    <% If bShowForm Then %>
    <form method="post" action="pForm.asp">
    >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


    <> wrote in message
    news:...
    >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>
    > <body>
    > <form method="post" action="pForm.asp">
    >>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>
    >
     
    Ray Costanzo [MVP], Oct 2, 2005
    #2
    1. Advertising

  3. Guest

    Many Thanks Ray

    Karen
     
    , Oct 2, 2005
    #3
  4. Guest

    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
     
    , Oct 3, 2005
    #4
  5. 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



    <> wrote in message
    news:...
    > 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
    >
     
    Ray Costanzo [MVP], Oct 4, 2005
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    2
    Views:
    6,247
  2. Rune
    Replies:
    6
    Views:
    1,268
    Richie Hindle
    Jan 29, 2004
  3. Jason
    Replies:
    1
    Views:
    2,329
    Alexey Smirnov
    Dec 14, 2009
  4. Chuck
    Replies:
    0
    Views:
    270
    Chuck
    Nov 10, 2003
  5. Replies:
    1
    Views:
    161
Loading...

Share This Page