rusa21
05-16-2010, 11:05 AM
I wrote a .asp form with 3 text boxes on it, intending for users to enter the appropriate data, and have the form post to another .asp page that creates session variables out of the input from the 3 textboxes. This works flawlessly. I then decided to change one of the text boxes to a dynamic drop list, so that the users couldn’t accidentally enter an invalid account number in the first box. Now they have to select one of the existing account numbers from the list, and type a name and phone number in the other two boxes. The problem is, now that the first text box is a drop list, the session variable creation is not happening when you submit the form. Below is an example of the code I used:
From the first page that used to have 3 textboxes, and now has 1 drop list and 2 text boxes: (this code queries the account number list from the DB file and populates the drop list from it, then writes the form to the .asp page and waits for the user to submit it.)
Set objRs = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT distinct(newSSID) FROM tblCallCenter "
objRS.Open strSQL, objconn
Response.Write "<form action=" & "'support2a.asp'" & "method=" & "'post'" & ">"
Response.Write "Network Name: "
Response.Write "<select name=" & "'list01'" & "id=" & "'list01'" & ">" & "<option value='''' selected>Pick One</option>"
Do While Not objRS.EOF
Response.Write "<option value=''" & objrs("newSSID") &"''>"& objRs("newSSID") &"</option>"
objRS.MoveNext
Loop
Response.Write "</select>" & "<a href=" & "'#network'" & ">" & " Click here if they don't know it" & "</a>" & "<br>"
Response.Write "Customer Name: "
Response.Write "<input name=" & "'txtName'" & "type=" & "'text'" & "id=" & "'txtName'" & ">" & "<br>"
Response.Write "Customer Phone: "
Response.Write "<input name=" & "'txtPhone'" & "type=" & "'text'" & "id=" & "'txtPhone'" & ">"
Response.Write "(we prefer a cell phone if possible)" & "<br>"
Response.Write "<input type=" & "'submit'" & "name=" & "'Submit'" & "value=" & "'Submit'" & ">"
Response.Write "</form>"
objRs.Close
objconn.Close
From the receiving page, the code that sets up the session variables:
<%session("name")=Request.Form("txtName")%>
<%session("phone")=Request.Form("txtPhone")%>
<%session("network")=Request.Form("list01")%>
I don’t care how many times I try to research this online, nobody has the solution in any online posting.
To test the creation of these variables, I appended the following code to the end of the second page:
Response.Write "Session Variable name is set to:"
Response.Write session("name")
Response.Write "<br>"
Response.Write "Session Variable phone is set to:"
Response.Write session("phone")
Response.Write "<br>"
Response.Write "Session Variable network is set to:"
Response.Write session("network")
The third session variable (“network”) is null. If I change the field on the first page back to a text box and type the account number in manually, all works perfectly. If I try to read the value of the drop list in using the <%session("network")=Request.Form("list01")%> code, it completely ignores the value of the drop list, the session variable is null, and my application fails.
9 hours researching on this so far and no luck...
From the first page that used to have 3 textboxes, and now has 1 drop list and 2 text boxes: (this code queries the account number list from the DB file and populates the drop list from it, then writes the form to the .asp page and waits for the user to submit it.)
Set objRs = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT distinct(newSSID) FROM tblCallCenter "
objRS.Open strSQL, objconn
Response.Write "<form action=" & "'support2a.asp'" & "method=" & "'post'" & ">"
Response.Write "Network Name: "
Response.Write "<select name=" & "'list01'" & "id=" & "'list01'" & ">" & "<option value='''' selected>Pick One</option>"
Do While Not objRS.EOF
Response.Write "<option value=''" & objrs("newSSID") &"''>"& objRs("newSSID") &"</option>"
objRS.MoveNext
Loop
Response.Write "</select>" & "<a href=" & "'#network'" & ">" & " Click here if they don't know it" & "</a>" & "<br>"
Response.Write "Customer Name: "
Response.Write "<input name=" & "'txtName'" & "type=" & "'text'" & "id=" & "'txtName'" & ">" & "<br>"
Response.Write "Customer Phone: "
Response.Write "<input name=" & "'txtPhone'" & "type=" & "'text'" & "id=" & "'txtPhone'" & ">"
Response.Write "(we prefer a cell phone if possible)" & "<br>"
Response.Write "<input type=" & "'submit'" & "name=" & "'Submit'" & "value=" & "'Submit'" & ">"
Response.Write "</form>"
objRs.Close
objconn.Close
From the receiving page, the code that sets up the session variables:
<%session("name")=Request.Form("txtName")%>
<%session("phone")=Request.Form("txtPhone")%>
<%session("network")=Request.Form("list01")%>
I don’t care how many times I try to research this online, nobody has the solution in any online posting.
To test the creation of these variables, I appended the following code to the end of the second page:
Response.Write "Session Variable name is set to:"
Response.Write session("name")
Response.Write "<br>"
Response.Write "Session Variable phone is set to:"
Response.Write session("phone")
Response.Write "<br>"
Response.Write "Session Variable network is set to:"
Response.Write session("network")
The third session variable (“network”) is null. If I change the field on the first page back to a text box and type the account number in manually, all works perfectly. If I try to read the value of the drop list in using the <%session("network")=Request.Form("list01")%> code, it completely ignores the value of the drop list, the session variable is null, and my application fails.
9 hours researching on this so far and no luck...