Problem with variable inside a for cycle

Author Message
Maika

  • Total Posts : 1
  • Scores: 0
  • Reward points : 0
  • Joined: 3/11/2008
  • Status: offline
Problem with variable inside a for cycle Tuesday, March 11, 2008 11:27 PM (permalink)
0
Hi.
 
I´m new in the forum and i start with a problem i´m having in my code and hope you can help me out.
 
The code is related with a search for products in my database.
 
The problem is that in the for cycle that i have to make the pages ( if there are more then 30 products ) my variable to send through the querystring link is not complete.
If i make the search with just one word it goes ok, but if i place 2 words separated by space it only shows the first word.
The for cycle is only to make the page links, it doesn´t affect the variable at all.
Here is some code:
 
' this code receives the variable that comes from the text form ) 
Dim exemplo
example=strText2
 
At this stage if a print example it shows the right value. ( either if it´s one word ore more, no problem until here )
 
 
' this code is to make all the necessary pages in a link to go to the next page
 
pages = "  "
 For l = 1 to ipage
  If l = page then
  
   pages = pages &  "  [" & page & "]   "
  
  Else
      
      response.write "Go 24"
      response.write "<br><br>"
      response.write example
      response.write "<br><br>"
      
    pages = pages & " <a class='pagpesquisa' href=searchaction.asp?pesquisa="&example&"&intPrice="&intPrice&"&chkPrice="&chkPrice&"&strCat="&strCat&"&chkCat="&chkCat&"&page=" &l&">" & l &  "</a>" & " &nbsp;"

  End If
 Next
 
 
When a run this code i get a pass on the G0 24 and i print the EXAMPLE and it show right ( team magic ) - team magic is the variable value.
Here is the print:
 
Go 24 ( this e a response.write to mke sure that i was going in the right way )

team magic ( this is the response.write of the search variable )
 
But when i move the mouse pointer into the second page in the browser it only shows (team)
Here is the link that it shows:
searchaction.asp?pesquisa=team
 
Also it is ignoring the other variables, but i think it is ignoring the other variables because of the first one ( example ).
 
If i make a search of only one word the result is the following as a link: (bateria is the search word)
searchaction.asp?pesquisa=bateria&intPrice=&chkPrice=&strCat=&chkCat=&page=2
 
We can see the other varaibles empty but that is not a problem to my code.
 
Any thoughts ?
If you need to test the code i can supply the link of my store. ( you can check it in english )
 
Thanks.
 
Alex

 
 
 
 
 
 
 
 
 
#1
    mcnd

    • Total Posts : 50
    • Scores: 2
    • Reward points : 0
    • Joined: 4/27/2008
    • Status: offline
    RE: Problem with variable inside a for cycle Tuesday, May 13, 2008 10:25 PM (permalink)
    0
    Hi

    Your problem is the space inside the example variable. No spaces allowed in querystring

    Solution:

    .....
       pages = pages & " <a class='pagpesquisa' href=searchaction.asp?pesquisa=" & Server.URLEncode(example) & "&intPric ......
    .....


    Hope it helps
     
    #2

      Online Bookmarks Sharing: Share/Bookmark

      Jump to:

      Current active users

      There are 0 members and 1 guests.

      Icon Legend and Permission

      • New Messages
      • No New Messages
      • Hot Topic w/ New Messages
      • Hot Topic w/o New Messages
      • Locked w/ New Messages
      • Locked w/o New Messages
      • Read Message
      • Post New Thread
      • Reply to message
      • Post New Poll
      • Submit Vote
      • Post reward post
      • Delete my own posts
      • Delete my own threads
      • Rate post

      2000-2012 ASPPlayground.NET Forum Version 3.9