473,378 Members | 1,688 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Back on itself

1
Hi
I have a pop up form that references a query string from a previous page successfully.

Expand|Select|Wrap|Line Numbers
  1. <%
  2. Dim rs_test
  3. Dim rs_test_cmd
  4. Dim rs_test_numRows
  5.  
  6. Set rs_test_cmd = Server.CreateObject ("ADODB.Command")
  7. rs_test_cmd.ActiveConnection = MM_conn_Sidecounter_STRING
  8. rs_test_cmd.CommandText = "SELECT * FROM tblSchoolPrograms WHERE DataCollect2ID=" & request.QueryString("count")& "" 
  9. rs_test_cmd.Prepared = true
  10.  
  11. Set rs_test = rs_test_cmd.Execute
  12. rs_test_numRows = 0
  13. %>
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)

Expand|Select|Wrap|Line Numbers
  1. <%
  2. Dim strScriptName
  3. Dim strInputText
  4. Dim strInputText2
  5.  
  6. ' Read in the script name so I know where to
  7. ' point the form's action to.
  8. strScriptName = Request.ServerVariables("URL")
  9.  
  10. ' Read in the input from the text area.
  11. strInputText = Request.Form("txtWordCount")
  12. strInputText2 = Request.Form("txtWordCount2")
  13.  
  14. ' Check for empty input and ignore it...
  15. If strInputText = "" Then
  16.     strInputText = ""
  17. Else
  18.     ' Echo out the input:
  19.     'Response.Write "You entered:<br />" & vbCrLf
  20.     'Response.Write "<pre>"
  21.     'Response.Write Server.HTMLEncode(strInputText)
  22.     'Response.Write "</pre>" & vbCrLf
  23.  
  24.     ' Print out the counts we got:
  25.     Response.Write "<p>The word count for Project Descriptions is <b>" _
  26.         & GetWordCount(strInputText) _
  27.         & "</b> words and <b>" _
  28.         & GetCharCount(strInputText) _
  29.         & "</b> characters.</p><br />" & vbCrLf
  30. End If
  31.  
  32. If strInputText2 = "" Then
  33.     strInputText2 = ""
  34. Else
  35.     ' Echo out the input:
  36.     'Response.Write "You entered2:<br />" & vbCrLf
  37.     'Response.Write "<pre>"
  38.     'Response.Write Server.HTMLEncode(strInputText)
  39.     'Response.Write "</pre>" & vbCrLf
  40.  
  41.     ' Print out the counts we got:
  42.     Response.Write "<p>The word count for Project Outcomes is <b>" _
  43.         & GetWordCount(strInputText2) _
  44.         & "</b> words and <b>" _
  45.         & GetCharCount(strInputText2) _
  46.         & "</b> characters.</p><br />" & vbCrLf
  47. End If
  48.  
  49. ' I wrapped these into functions so you can reuse them.
  50. '**** Begin Functions ***********************************
  51. Function GetWordCount(strInput)
  52.     Dim strTemp
  53.  
  54.     ' Deal with tabs and carriage returns
  55.     ' by replacing them with spaces.
  56.     strTemp = Replace(strInput, vbTab, " ")
  57.     strTemp = Replace(strTemp, vbCr, " ")
  58.     strTemp = Replace(strTemp, vbLf, " ")
  59.  
  60.     ' Remove leading and trailing spaces
  61.     strTemp = Trim(strTemp)
  62.  
  63.     ' Combine multiple spaces down to single ones
  64.     Do While InStr(1, strTemp, "  ", 1) <> 0
  65.         strTemp = Replace(strTemp, "  ", " ")
  66.     Loop
  67.  
  68.     ' Get a count by splitting the string into an array
  69.     ' and retreiving the number of elements in it.
  70.     ' I add one to deal with the 0 lower bound.
  71.     GetWordCount = UBound(Split(strTemp, " ", -1, 1)) + 1
  72. End Function ' GetWordCount
  73.  
  74. Function GetCharCount(strInput)
  75.     GetCharCount = Len(strInput)
  76. End Function ' GetCharCount
  77. '**** End Functions *************************************
  78. ' Here's our form that we fill with the value they
  79. ' entered last time.
  80. %>
  81.  
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
Aug 20 '08 #1
1 1187
DrBunchman
979 Expert 512MB
Hi Peter,

I'm a little bit confused about what it is you're trying to do. Are you trying redirect the page to another page while populating the querystring?

If so you can use Response.Redirect like this:
Expand|Select|Wrap|Line Numbers
  1. strcollectpage = request.QueryString(rs_collect)
  2. strpathRoute = request.ServerVariables("URL")
  3. strScriptName = strpathRoute & "?count=" & strcollectpage
  4. Response.Redirect strScriptName
Does that help? If not can you clarify your problem for me please.

Dr B
Aug 21 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Galina | last post by:
Hello I have 6 dependent list boxes on my ASP page:  Faculty;  Lecturer;  Course;  Course occurrence;  Group;  Week commencing date. When faculty is selected, lists of lecturers and...
6
by: Mark | last post by:
I have two dropdown lists. Both have autopostback set to true. In both dropdowns, when you select an item from the list, it redirects to the Value property of the dropdown. Nothing fancy. ...
5
by: ns21 | last post by:
How can the browser back button be disabled If the form is submitting information to other pages or submitting to itself or using redirections. I tried the tweaks like history.forward(1) in each...
11
by: prophet | last post by:
Here is a simple on that I need help with..... I need to create a link "back" that when you click it, it returns you back to the previous page that you were at. I am not looking for button...
25
by: zmickle | last post by:
Excuse my noobness. I am managing an access database that is shared by 4 users. Management does not want to use any technologies outside of access for this application (no SQL Server, etc). I...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.