Hi
I have a pop up form that references a query string from a previous page successfully.
- <%
-
Dim rs_test
-
Dim rs_test_cmd
-
Dim rs_test_numRows
-
-
Set rs_test_cmd = Server.CreateObject ("ADODB.Command")
-
rs_test_cmd.ActiveConnection = MM_conn_Sidecounter_STRING
-
rs_test_cmd.CommandText = "SELECT * FROM tblSchoolPrograms WHERE DataCollect2ID=" & request.QueryString("count")& ""
-
rs_test_cmd.Prepared = true
-
-
Set rs_test = rs_test_cmd.Execute
-
rs_test_numRows = 0
-
%>
It uses this number to populate 2 text fields in a form successfully. I the have a submit button on the form that calculates a word count. (free code from the web I have adjusted)
- <%
-
Dim strScriptName
-
Dim strInputText
-
Dim strInputText2
-
-
' Read in the script name so I know where to
-
' point the form's action to.
- strScriptName = Request.ServerVariables("URL")
-
-
' Read in the input from the text area.
-
strInputText = Request.Form("txtWordCount")
-
strInputText2 = Request.Form("txtWordCount2")
-
-
' Check for empty input and ignore it...
-
If strInputText = "" Then
-
strInputText = ""
-
Else
-
' Echo out the input:
-
'Response.Write "You entered:<br />" & vbCrLf
-
'Response.Write "<pre>"
-
'Response.Write Server.HTMLEncode(strInputText)
-
'Response.Write "</pre>" & vbCrLf
-
-
' Print out the counts we got:
-
Response.Write "<p>The word count for Project Descriptions is <b>" _
-
& GetWordCount(strInputText) _
-
& "</b> words and <b>" _
-
& GetCharCount(strInputText) _
-
& "</b> characters.</p><br />" & vbCrLf
-
End If
-
-
If strInputText2 = "" Then
-
strInputText2 = ""
-
Else
-
' Echo out the input:
-
'Response.Write "You entered2:<br />" & vbCrLf
-
'Response.Write "<pre>"
-
'Response.Write Server.HTMLEncode(strInputText)
-
'Response.Write "</pre>" & vbCrLf
-
-
' Print out the counts we got:
-
Response.Write "<p>The word count for Project Outcomes is <b>" _
-
& GetWordCount(strInputText2) _
-
& "</b> words and <b>" _
-
& GetCharCount(strInputText2) _
-
& "</b> characters.</p><br />" & vbCrLf
-
End If
-
-
' I wrapped these into functions so you can reuse them.
-
'**** Begin Functions ***********************************
-
Function GetWordCount(strInput)
-
Dim strTemp
-
-
' Deal with tabs and carriage returns
-
' by replacing them with spaces.
-
strTemp = Replace(strInput, vbTab, " ")
-
strTemp = Replace(strTemp, vbCr, " ")
-
strTemp = Replace(strTemp, vbLf, " ")
-
-
' Remove leading and trailing spaces
-
strTemp = Trim(strTemp)
-
-
' Combine multiple spaces down to single ones
-
Do While InStr(1, strTemp, " ", 1) <> 0
-
strTemp = Replace(strTemp, " ", " ")
-
Loop
-
-
' Get a count by splitting the string into an array
-
' and retreiving the number of elements in it.
-
' I add one to deal with the 0 lower bound.
-
GetWordCount = UBound(Split(strTemp, " ", -1, 1)) + 1
-
End Function ' GetWordCount
-
-
Function GetCharCount(strInput)
-
GetCharCount = Len(strInput)
-
End Function ' GetCharCount
-
'**** End Functions *************************************
-
' Here's our form that we fill with the value they
-
' entered last time.
-
%>
-
The problem is as a static page it all works perfectly and counts successfully. But when done dynamically it obviously can't reference itself to repopulate the query string.
I have tried to adjust the strscriptname with
strcollectpage = request.QueryString(rs_collect)
strpathRoute = request.ServerVariables("URL")
strScriptName = strpathRoute & "?count=" & strcollectpage
My coding is not that good and I have reached a stalemate, errors galore.
Any help would be great
Cheers
Peter