Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Mar 2006
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    asp form question

    I DON'T need a php solution, or anything else, other than an html, asp, or javascript solution to this question.

    When a user fills out a form, I need to allow them to go back with the fields they already filled out, STILL HAVING THE DATA THERE, to finish filling out remaining fields that were required, but which they overlooked.
    This eliminates them having to start all over again.

    Thanks in advance.
    Steve

  • #2
    New Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    35
    Thanks
    0
    Thanked 0 Times in 0 Posts
    When I do this I just code a bit of asp that checks the required fields are entered, if not, I get the <body> tag to run off of javascript function to return to the previous page, eg.

    <%
    Dim goBack
    If Request.Form("requiredField")="" Then
    goBack=true
    End If

    Dim onloadAction
    If goBack Then
    onloadAction=" onLoad='retry()'"
    End If
    %>

    <script language="javascript">
    <!--
    function retry() {
    alert('Please ensure all required fields are completed! ');
    window.history.back();
    //-->
    }
    </script>

    <body <%=onloadAction%>>

    Hope that helps.

  • #3
    New Coder
    Join Date
    Mar 2005
    Posts
    50
    Thanks
    0
    Thanked 2 Times in 2 Posts
    Hi Steve,

    add a value attribute with a little ASP to the form inputs you want 'remebered'
    Code:
    <input name="somename" value="<%= Request.Form("somename") %>" />
    see the munki click- was that so random?

  • #4
    Senior Coder
    Join Date
    Nov 2002
    Location
    North-East, UK
    Posts
    1,265
    Thanks
    0
    Thanked 0 Times in 0 Posts
    As above, the easiest way it to post a form to itsself then you have the Request.Form collection available.


    Code:
    <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
    <%
    If Len(Request.Form) > 0 Then
    	If Request.Form("name") = "" Then
    		errMsg = errMsg & "- Name is required<br>"
    	End If
    	
    	If Request.Form("message") = "" Then
    		errMsg = errMsg & "- Message is required<br>"
    	End If
    	
    	If Len(errMsg) > 0 Then
    		errMsg = "Error: There was a problem with your form submittal<br>" & errMsg
    	Else
    		Server.Transfer("processing.asp")
    	End If
    End If
    %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>Untitled Document</title>
    </head>
    
    <body>
    <span style="color: red"><%=errMsg%></span>
    <form name="form1" method="post" action="">
      <p>
        Name: 
        <input type="text" name="name" value="<%=Request.Form("name")%>">
    </p>
      <p>Message:<br>
        <textarea name="message"><%=Request.Form("message")%></textarea>
    </p>
      <p>
        <input type="submit" name="Submit" value="Submit">
      </p>
    </form>
    </body>
    </html>
    Last edited by degsy; 05-02-2006 at 04:42 PM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •