troubleshooting Question

Populate form with previously submitted information

Avatar of Malloy1446
Malloy1446 asked on
ASPHTMLSQL
6 Comments1 Solution119 ViewsLast Modified:
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>
ASKER CERTIFIED SOLUTION
Big Monty
Web Ninja at large

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 6 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros