...

View Full Version : asp form question



steveinchicago
05-01-2006, 07:56 PM
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

ihitman
05-02-2006, 11:34 AM
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.

chud_wallice
05-02-2006, 01:52 PM
Hi Steve,

add a value attribute with a little ASP to the form inputs you want 'remebered'


<input name="somename" value="<%= Request.Form("somename") %>" />

degsy
05-02-2006, 03:37 PM
As above, the easiest way it to post a form to itsself then you have the Request.Form collection available.




<%@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>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum