Hello I am trying to pass a variable from one ASP page to another and am having difficulties. I do not know what I need to do to pass the field rs.Fields("ContactEmail"), referenced below, to the next page using either a session varible or a QueryString... I have attached some of the code so that you can take a look at it. Any suggestions would be greatly apprieciated! <% Option Explicit %> Set conn = Server.CreateObject("ADODB.Connection") conn.Open connString Dim sql, rs Set rs = Server.CreateObject("ADODB.Recordset") Dim tenantContact tenantContact = "" If Request.Form("refresh") = "1" Then setSessionValues() If Request.Form("newTenant") <> "0" Then Dim newTenantID newTenantID = Request.Form("newTenant") sql = "SELECT * FROM TblTenantContact WHERE TenantID = " & newTenantID rs.Open sql, conn If Not rs.EOF Then Do Until rs.EOF tenantContact = tenantContact & "<table width='300' cellpadding='0' cellspacing='0' border='0'>" tenantContact = tenantContact & "<tr><td width='100'>Name:</td>" tenantContact = tenantContact & "<td width='200'>" & rs.Fields("ContactName") & "</td></tr>" tenantContact = tenantContact & "<tr><td>Position:</td><td>" & rs.Fields("ContactPosition") & "</td></tr>" tenantContact = tenantContact & "<tr><td>Phone:</td><td>" & rs.Fields("ContactPhone") & "</td></tr>" tenantContact = tenantContact & "<tr><td>E-mail:</td><td>" & rs.Fields("ContactEmail") & "</td></tr>" rs.MoveNext Loop End If rs.Close End If End If Dim jID, tID jID = Request.QueryString("jID") tID = Request.QueryString("tID") If Not IsNull(tID) And tID <> "" Then sql = "SELECT * FROM TblTenantContact WHERE TenantID = " & tID rs.Open sql, conn If Not rs.EOF Then Do Until rs.EOF & "<tr><td>E-mail:</td><td>" & rs.Fields("ContactEmail") & "</td></tr>" tenantContact = tenantContact & "<tr><td colspan='2'> </td></tr></table>" rs.MoveNext Loop End If rs.Close End If %> <form action="ServiceRequestAdd.asp" method="post" name="AddSRForm"> <input type="hidden" name="refresh" value="0" /> <input type="hidden" name="newTenant" value="0"> **If a insert a non variable as the value the passing of the variable works fine** <input type="hidden" name="ContactEmail" value="???????"> <table border="0" cellspacing="0" cellpadding="1" width="100%"> <tr> <td>Job Site: <span style="color:red">*</span></td> <td><select name="selJobSite" onchange="showTenant(this.value)"><option value="0">Select Job Site</option> rs.MoveNext </select> </td> </tr> <tr> <td>Tenant: <span style="color:red">*</span></td> <% If Session.Contents("JobSite") <> "" Or jID <> "" Then %> <select name="selTenant" onchange="getContact(this.form, this.options[this.selectedIndex].value)"> <option value="0">Select Tenant</option> <% If Session.Contents("JobSite") <> "" Then sql = "SELECT * FROM TblTenant WHERE JobSiteID = " & CInt(Session.Contents("JobSite")) Else sql = "SELECT * FROM TblTenant WHERE JobSiteID = " & CInt(jID) End If rs.Open sql, conn If Not rs.EOF Then Do Until rs.EOF If CInt(rs.Fields("TenantID")) = CInt(Session.Contents("Tenant")) Or CInt(tID) = CInt(rs.Fields("TenantID")) Then %> <option value="<%=rs.Fields("TenantID")%>" selected><%=rs.Fields("TenantName")%></option> <% Else %> <option value="<%=rs.Fields("TenantID")%>"><%=rs.Fields("TenantName")%></option> <% End If %> Loop End If rs.Close %> </select> </div> </td> </tr> ....................... <th colspan="2" align="left"><b>Tenant's Contact Information:</b></th> <tr> <td> </td> <td><%=tenantContact%></td> </tr> </table> </form> <% conn.Close Set rs = Nothing Set conn = Nothing Sub setSessionValues() Session.Contents("JobSite") = Request.Form("selJobSite") Session.Contents("Tenant") = Request.Form("selTenant") Session.Contents("RequestType") = Request.Form("selRequestType") Session.Contents("Problem") = Request.Form("selProblem") Session.Contents("Details") = Request.Form("txtDetails") Session.Contents("AssignedTo") = Request.Form("selAssignedTo") Session.Contents("TenantNote") = Request.Form("txtTenantNote") Session.Contents("ProgressNote") = Request.Form("txtProgressNote") Session.Contents("ContactEmail") = Request.Form("ContactEmail") End Sub %>
Are you saying everything is ok with the exception of that field? What is the issue you are having? Error? Session just not appended?
Everything else is working fine. The only problem is that I can not pass the Request.Form("ContactEmail") variable to the next page. I need to pass this variable to the next page because that page submits the variable to a database. Thanks!
As I said in my first email... if I pass the valiable as a static value in a hidden input type the next page works fine... <input type="hidden" name="ContactEmail" value="THIS DATA GETS INSERTED INTO DB FINE"> Thanks again for any insite!!
The form is a little confusing because it looks like you are doing multiple things in one form. First off it looks like you are capturing the data then hiding it in the same page and then looping through the process. It gets a little confusing. Rather try creating a small but simple test script and see if you can pass it to another simple test page. Use Response.Write to view if the objects are being passed correctly. From there increase the complexity of the test scrip and see where it maybe failing. It may take some extra work doing this but in the long run I think you may find that it avoids many headaches.
Thanks Ray. I have done that with all other variables and the data has been sent successfully. This is the only variable that I cant seem to pass successfully? I do not know if I should try to past it as a session variable or a quarry string.
Below is the code that I use in the following page. As you can see I am trying to use Session.Contents("ContactEmail") (Although unsuccessfully) to add the Service Request to the db. <% Dim sql, rs, rs2, srID Set conn = Server.CreateObject("ADODB.Connection") conn.Open connString Set rs = Server.CreateObject("ADODB.Recordset") Set rs2 = Server.CreateObject("ADODB.Recordset") Dim selJobSite, selTenant, selRequestType, selProblem, txtDetails, selAssignedTo Dim txtTenantNote, txtProgressNote Dim chkSendContact, chkSendBO, chkSendAssigned, tenantEmail selJobSite = Request.Form("selJobSite") selTenant = Request.Form("selTenant") selRequestType = Request.Form("selRequestType") selProblem = Request.Form("selProblem") txtDetails = Request.Form("txtDetails") selAssignedTo = Request.Form("selAssignedTo") txtTenantNote = Request.Form("txtTenantNote") txtProgressNote = Request.Form("txtProgressNote") chkSendContact = Request.Form("chkSendContact") chkSendBO = Request.Form("chkSendBO") chkSendAssigned = Request.Form("chkSendAssigned") tenantEmail = Session.Contents("ContactEmail") 'Add Service Request rs.Open "TblServiceRequest", conn, adOpenKeyset, adLockOptimistic rs.AddNew rs.Fields("SRStatusID") = 1 rs.Fields("JobSiteID") = selJobSite rs.Fields("TenantID") = selTenant rs.Fields("DateCreated") = Date() rs.Fields("TimeCreated") = Time() rs.Fields("CreatedBy") = Session.Contents("UserFullName") rs.Fields("SRRequestTypeID") = selRequestType rs.Fields("SRProblemID") = selProblem rs.Fields("Details") = txtDetails rs.Fields("ContactEmail") = tenantEmail If selAssignedTo <> "0" Then rs.Fields("AssignedTo") = selAssignedTo End If rs.Fields("TenantNote") = txtTenantNote rs.Fields("ProgressNote") = txtProgressNote rs.Update
All other variables are submitted successfully to the table "TblServiceRequest" but the ContactEmail field remains NULL.
As a test for now and providing that your database data type permits it, try inputting 'ContactEmail' as a straight string on your form. Instead of inputting ([email protected]) as an example try inputting just (email.email.com). Lets see how this reacts. On the form page you may want to drop any validation for now.