Solved

Populate form with previously submitted information

Posted on 2014-12-27
6
73 Views
Last Modified: 2015-01-01
I have a form which asks for some personal information. Then an option to select a type with additional information to enter. Once the form is complete, the user submits the data and it is entered in an MSDatabase and sent via email. On the submit page, I want to include an option to submit another request (line 243) and automatically include the users personal information. There are 5 fields I want to include (ILLRequestorsFName, ILLRequestorsLName, ILLRequestorsService, ILLRequestorsEmail, ILLRequestorsPhone).

The form is Eligible.asp.
The confirmation page is Eligible2.asp

I am including the code for Eligible2.asp.

<%@LANGUAGE="VBSCRIPT"%>

<!-- #Include Virtual="CodeReuse/ConnTesting.inc" -->

<%
'response.Write("chartID: " & session("ChartID"))
'response.End()
%>

<%
dim title
title = "Form"

'--------------------------------------------------------------------------------------------
dim ChartID
ChartID = session("ChartID")
	

'--------------------------------------------------------------------------------------------
dim sql2, RSListRecipients
	
	sql2= "SELECT SDEmail FROM tblStaffDirectory WHERE ChartID=" & ChartID & " and ILLContact='Y'"

'response.Write("sql2: " & sql2)
'response.End()
			
		set RSListRecipients = objConn.Execute(sql2)


'--------------------------------------------------------------------------------------------

'insert the information from the previous page into the database

dim objRS, strCol, ILLID

'open recordset
'open recordset where the data from the previous page will be stored


sql = "Select * FROM tblILLRequests WHERE (ILLID = " & Request.form("ILLID") & ")"

	Set objRS = Server.CreateObject("ADODB.Recordset")
	objRS.Open "tblILLRequests", objConn, adOpenStatic, adLockOptimistic, adCmdTable

	'Crete new record.
	objRS.AddNew
	'Input data in tblILLRequests.
	For each strCol in Request.Form
		If Len(Request(strCol)) > 0 then
				objRS(strCol) = Request.Form(strCol)
			End If
	Next
'Write the record to the database.
objRS.Update

'Get the unique ID of the record we just created. 
'We'll use this ID in the other tables, and will pass it to subsequent pages in a hidden form field.

Set objRS = objConn.Execute( "SELECT @@IDENTITY" )
ILLID = objRS(0)

objRS.close


'---------------------------------------------- Mail function ---------------------------------------
'Following is code to send email

dim strRecips
strRecips = "email@gmail.com"


While Not RSListRecipients.EOF
'Following line displays the requestor's email
	response.Write("<br/>" & RSListRecipients("SDEmail"))
	strRecips = strRecips & RSListRecipients("SDEmail") & ";"
	RSListRecipients.MoveNext
Wend

'following line displays WHO the message is sent to
'Response.Write("<br/>" & strRecips)

txtTo = strRecips



'---------------------------------------------- Body of email ---------------------------------------
txtFrom = request.form("ILLRequestorsEmail")

txtSub = "ILL Online Request"

txtBody = "Requestor's Name: " & request.form("ILLRequestorsFName") & " " & request.form("ILLRequestorsLName")
txtBody = txtBody & "<br>Service: " & request.form("ILLRequestorsService")
txtBody = txtBody & "<br>Email: " & request.form("ILLRequestorsEmail")
txtBody = txtBody & "<br>Phone: " & request.form("ILLRequestorsPhone")

	txtBody = txtBody & "<p>&nbsp;&nbsp;Type of Request: " & request.form("ILLRequestType")

	IF request.form("ILLRequestType") = "Book" THEN
		txtBody = txtBody & "<p>&nbsp;&nbsp;Book Author: " & request.form("ILLBookAuthor")
		txtBody = txtBody & "<br>&nbsp;&nbsp;Book Title: " & request.form("ILLBookTitle")
		txtBody = txtBody & "<br>&nbsp;&nbsp;ISBN: " & request.form("ILLBookISBN")
		txtBody = txtBody & "<br>&nbsp;&nbsp;Book Chapter: " & request.form("ILLBookChapter")
		txtBody = txtBody & "<br>&nbsp;&nbsp;Book Chapter Pages: " & request.form("ILLBookChapterPages")
		txtBody = txtBody & "<br>&nbsp;&nbsp;Publisher: " & request.form("ILLBookPublisher")
		txtBody = txtBody & "<br>&nbsp;&nbsp;Publication Date: " & request.form("ILLBookPubYear")
		txtBody = txtBody & "<br>&nbsp;&nbsp;Edition: " & request.form("ILLBookEd")
	END IF
	
	IF request.form("ILLRequestType") = "Audiovisual" THEN
		txtBody = txtBody & "<p>&nbsp;&nbsp;Audiovisual Title: " & request.form("ILLAVTitle")
		txtBody = txtBody & "<br>&nbsp;&nbsp;Producer: " & request.form("ILLAVProducer")
		txtBody = txtBody & "<br>&nbsp;&nbsp;Production Year: " & request.form("ILLAVProductionYear")
	END IF
	
	IF request.form("ILLRequestType") = "Journal Article" THEN
		txtBody = txtBody & "<p>&nbsp;&nbsp;Journal Title: " & request.form("ILLJournalTitle")
		txtBody = txtBody & "<br>&nbsp;&nbsp;ISSN: " & request.form("ILLJournalISSN")
		txtBody = txtBody & "<br>&nbsp;&nbsp;Volume: " & request.form("ILLJournalVolume")
		txtBody = txtBody & "&nbsp;&nbsp;Issue: " & request.form("ILLJournalIssue") 
		txtBody = txtBody & "&nbsp;&nbsp;Publication Date: " & request.form("ILLJournalPubDate") 
		txtBody = txtBody & "<br>&nbsp;&nbsp;PMID: " & request.form("ILLJournalPMID")
		txtBody = txtBody & "<br>&nbsp;&nbsp;Journal Article: " & request.form("ILLJournalArticle")
		txtBody = txtBody & "<br>&nbsp;&nbsp;Author: " & request.form("ILLJournalArticleAuthor")
		txtBody = txtBody & "<br>&nbsp;&nbsp;Page range: " & request.form("ILLJournalPages")
	END IF

		txtBody = txtBody & "<br>&nbsp;&nbsp;Not needed after: " & request.form("ILLNotNeeded")
		txtBody = txtBody & "<br>&nbsp;&nbsp;Additional Info: " & request.form("ILLInfo")




%>

  <!-- #INCLUDE VIRTUAL="CodeReuse/Mailer2.asp" -->


<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title><%=title%></title>


<link rel=stylesheet type="text/css"
  href="CodeReuse/style.css">


</head>

<body>

<h2><%=title%> - Request Submitted</h2>


<p>&nbsp;</p>

<hr>


<div id="LrgPrt"><p align="center">

	Thank you for using the <b><i>Online Interlibrary Loan form</i></b>.
	<br>Your request has been sent to your facility library staff.

<hr>

<%
Response.Write "The following data has been submitted<p>"

Response.Write "<blockquote>"

Response.Write "<b>Name: </b>" & request.form("ILLRequestorsFName") & " " & request.form("ILLRequestorsLName")

If LEN(Request.form("ILLRequestorsService"))>0 THEN
	Response.Write "<br><b>Service: </b>" & request.form("ILLRequestorsService")
End If

Response.Write "<br><b>Email: </b>" & request.form("ILLRequestorsEmail")

If LEN(Request.form("ILLRequestorsPhone"))>0 THEN
	Response.Write "<br><b>Phone: </b>" & request.form("ILLRequestorsPhone")
End If


'---------------------------- Verification of AV Request ----------------------------
IF request.form("ILLRequestType") = "Audiovisual" THEN
	Response.Write "<blockquote><b>Audiovisual Request</b><br>"
		Response.Write "<br><b>Audiovisual Title: </b>" & request.form("ILLAVTitle")
		Response.Write "<br><b>Producer: </b>" & request.form("ILLAVProducer")
		Response.Write "<br><b>Production Year: </b>" & request.form("ILLAVProductionYear")

		Response.Write "<br><b>Not needed after: </b>" & request.form("ILLNotNeeded")
		Response.Write "<br><b>Additional Info: </b>" & request.form("ILLInfo")

	Response.Write "</blockquote>"
END IF
	

'-------------------------- Verification of Journal Request --------------------------

IF request.form("ILLRequestType") = "Journal Article" THEN
	Response.Write "<blockquote><b>Journal Article Request</b><br>"
		Response.Write "<br><b>Journal Title: " & request.form("ILLJournalTitle")
		Response.Write "<br><b>ISSN: " & request.form("ILLJournalISSN")
		Response.Write "<br><b>Volume: " & request.form("ILLJournalVolume")
		Response.Write "<br><b>Issue: " & request.form("ILLJournalIssue") 
		Response.Write "<br><b>Publication Date: " & request.form("ILLJournalPubDate") 
		Response.Write "<br><b>PMID: " & request.form("ILLJournalPMID")
		Response.Write "<br><b>Journal Article: " & request.form("ILLJournalArticle")
		Response.Write "<br><b>Author: " & request.form("ILLJournalArticleAuthor")
		Response.Write "<br><b>Page range: " & request.form("ILLJournalPages")

		Response.Write "<br><b>Not needed after: </b>" & request.form("ILLNotNeeded")
		Response.Write "<br><b>Additional Info: </b>" & request.form("ILLInfo")

	Response.Write "</blockquote>"
END IF


'-------------------------- Verification of Book Request --------------------------

IF request.form("ILLRequestType") = "Book" THEN
	Response.Write "<blockquote><b>Journal Article Request</b><br>"
		Response.Write "<br><b>Book Author: " & request.form("ILLBookAuthor")
		Response.Write "<br><b>Book Title: " & request.form("ILLBookTitle")
		Response.Write "<br><b>ISBN: " & request.form("ILLBookISBN")
		Response.Write "<br><b>Book Chapter: " & request.form("ILLBookChapter")
		Response.Write "<br><b>Book Chapter Pages: " & request.form("ILLBookChapterPages")
		Response.Write "<br><b>Publisher: " & request.form("ILLBookPublisher")
		Response.Write "<br><b>Publication Date: " & request.form("ILLBookPubYear")
		Response.Write "<br><b>Edition: " & request.form("ILLBookEd")

		Response.Write "<br><b>Not needed after: </b>" & request.form("ILLNotNeeded")
		Response.Write "<br><b>Additional Info: </b>" & request.form("ILLInfo")

	Response.Write "</blockquote>"
END IF
	

%>

Submit another request
<p>

</div>

        
</body>

</html>

Open in new window

0
Comment
Question by:Malloy1446
6 Comments
 
LVL 11

Expert Comment

by:John_Vidmar
ID: 40520459
Save the values in a form with hidden-fields; the submit-button (line 243) would be replaced with the following:
<form action="Eligible.asp" >
	<input type="hidden" name="ILLRequestorsFName"   value="<%=request.form("ILLRequestorsFName")%>"   />
	<input type="hidden" name="ILLRequestorsLName"   value="<%=request.form("ILLRequestorsLName")%>"   />
	<input type="hidden" name="ILLRequestorsService" value="<%=request.form("ILLRequestorsService")%>" />
	<input type="hidden" name="ILLRequestorsEmail"   value="<%=request.form("ILLRequestorsEmail")%>"   />
	<input type="hidden" name="ILLRequestorsPhone"   value="<%=request.form("ILLRequestorsPhone")%>"   />
	<input type="submit" value="Submit another request" />
</form> 

Open in new window

0
 

Author Comment

by:Malloy1446
ID: 40520672
I tried the suggested code with just one field. It returns to the Eligible.asp page with the following URL:

Eligible.asp?ILLRequestorsFName=bbb

Although the field is NOT filled in.
0
 
LVL 33

Expert Comment

by:Big Monty
ID: 40521982
do you have code on your form fields to read in these values? I would also change the form's method to POST:

eligible2.asp - line 243
<form action="Eligible.asp" method="POST" >
	<input type="hidden" name="ILLRequestorsFName"   value="<%=request.form("ILLRequestorsFName")%>"   />
	<input type="hidden" name="ILLRequestorsLName"   value="<%=request.form("ILLRequestorsLName")%>"   />
	<input type="hidden" name="ILLRequestorsService" value="<%=request.form("ILLRequestorsService")%>" />
	<input type="hidden" name="ILLRequestorsEmail"   value="<%=request.form("ILLRequestorsEmail")%>"   />
	<input type="hidden" name="ILLRequestorsPhone"   value="<%=request.form("ILLRequestorsPhone")%>"   />
	<input type="submit" value="Submit another request" />
</form> 

Open in new window


eligible.asp - whatever line your field is on:
<input type="text" name="ILLRequestorsFName" value="<%=Request("ILLRequestorsFName")%>" />

Open in new window

0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

Author Comment

by:Malloy1446
ID: 40522028
On eligible.asp I added the value.
On eligible2.asp my form code

<form action="Eligible.asp" method="POST">
	<input type="hidden" name="ILLRequestorsFName" value="request.form('ILLRequestorsFName')" />
	<input type="submit" value="Submit another request" />
</form>

Open in new window


When I click Submit, Eligible.asp displays request.form('ILLRequestorsFName') on the form
0
 
LVL 33

Accepted Solution

by:
Big Monty earned 500 total points
ID: 40522031
be sure to look at the code I posted carefully. You need to add it inside <% %> tags:

<input type="hidden" name="ILLRequestorsFName" value="<%=request.form('ILLRequestorsFName')%>" />
0
 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
ID: 40522933
Another options is in your insert code you are grabbing the an the identity id for tblILLRequests on line 60
ILLID = objRS(0).

Open in new window

You could also submit the field ILLID as a hidden field, session variable or cookie.  Then in your processing page, look up the data you need from tblILLRequests and copy it over.  

One advantage to this method is you will know for sure the personal data is not altered.  Even if you use a hidden field, it is still subject to change and as a rule you shouldn't trust input data.  

Still another option is to simply add a field "OriginalRquestID" and make the default value in your db zero.   When you submit the 2nd or any subsequent request, use the field ILLID to populate.  Then you can always grab the personal information from the original request.  As a side benefit, you track how many related requests are being made.
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question