Tema: Replace
Ver Mensaje Individual
  #3 (permalink)  
Antiguo 21/01/2009, 06:28
darkmcloud
 
Fecha de Ingreso: octubre-2007
Mensajes: 191
Antigüedad: 17 años, 7 meses
Puntos: 0
Respuesta: Replace

gracias por la pronta respuesta compadre Shiryu_libra...pero lo necesito porque tengo diseñada una pagina donde tengo creado un buscador con distintos criterios de busqueda donde tengo un paginador de resultados...(use el código de la barra de navegacion de las faqs) y paso las variables de la siguiente forma :

MisCondiciones =

"&codigo="&codigo&"&descrip="&descrip&"&familia="& familia&"&stock="&stock&""

y el problema me lo esta generando la variable "descrip"...porque en la primera página de resultados...y yo busco de esta forma : "%motor"....ningun problema..
pero en la siguiente página se pierde el caracter % y solo queda como "motor"

Bueno..este es el codigo de la pagina:


Código asp:
Ver original
  1. <%
  2.  
  3.  
  4. Function BarraDeNavegacion(PaginasTotales, PaginaActual, MisCondiciones)
  5. 'Modificar el contenido de las constantes para cambiar el aspecto de la barra de navegación
  6. const EstiloDeLaTabla = "border: 1px solid #D6AD6B; font-family: Arial, Helvetica, sans-serif; font-size: 12px;"
  7.     const EstiloCeldaPaginaXdeY = "color: white; background-color: black;"
  8.     const LinkDelEnlace = "link1"
  9.     const EstiloDeLaCeldaPaginaActual = "background-color:#EFD6AD; font-weight:bold;"
  10.     const EstiloDeLaCeldaPaginaConLink = "background-color:#F7E7C6"
  11.  
  12.  
  13.  
  14. MisCondiciones = "&v1="&v1&"&codigo="&codigo&"&descrip1="&descrip&"&familia="&familia&"&stock="&stock&""
  15.  
  16.  
  17.  
  18. if PaginasTotales > 1 then
  19. if PaginasTotales > 5 then MostrarUltima = true
  20. TablaConBarraDeNavegacion = "<table border=""0"" cellpadding=""2"" cellspacing=""1"" style=""" & EstiloDeLaTabla & """><tr><td style=""" & EstiloCeldaPaginaXdeY & """>&nbsp; P&aacute;gina " & PaginaActual & " de " & PaginasTotales & "&nbsp;&nbsp;</td>"
  21. if PaginaActual >= 4 then
  22. TablaConBarraDeNavegacion = TablaConBarraDeNavegacion & "<td style="""& EstiloDeLaCeldaPaginaConLink &"""><a href="""& PaginaActualBarraDeNavegacion & "?pagina=1" & MisCondiciones  &""" class="""    & LinkDelEnlace & """><strong>«</strong> Primera</a></td>"
  23. CantidadAMostrarDeAnterioresYPosteriores = 2
  24. 'Indicamos la celda central como activa, y sin link
  25. '(la 3ª, de las 5 mostradas), y el resto con link
  26. for i = 1 to 5
  27. 'No mostramos link si estamos en la 3ª celda de las 5 mostradas
  28. if i = 3 then
  29. TablaConBarraDeNavegacion = TablaConBarraDeNavegacion & "<td width=""15"" align=""center"" style=""" & EstiloDeLaCeldaPaginaActual & """>" & PaginaActual & "</td>"
  30. else
  31. 'Mostramos el link si estamos en las celdas distintas de la 3ª (la central)
  32. TablaConBarraDeNavegacion = TablaConBarraDeNavegacion & "<td width=""15"" align=""center"" style=""" & EstiloDeLaCeldaPaginaConLink & """><a href="""& PaginaActualBarraDeNavegacion & "?pagina=" & PaginaActual - CantidadAMostrarDeAnterioresYPosteriores & MisCondiciones  & """ class=""" & LinkDelEnlace &  """>" & PaginaActual - CantidadAMostrarDeAnterioresYPosteriores & "</a></td>"
  33. end if
  34.  
  35. if PaginaActual - CantidadAMostrarDeAnterioresYPosteriores = PaginasTotales then
  36. MostrarUltima = False
  37. Exit For
  38. end if
  39.  
  40. CantidadAMostrarDeAnterioresYPosteriores = CantidadAMostrarDeAnterioresYPosteriores - 1
  41. next
  42. else
  43. if PaginasTotales < 5 then
  44. for i = 1 to PaginasTotales
  45. if i <> PaginaActual then
  46. TablaConBarraDeNavegacion = TablaConBarraDeNavegacion & "<td width=""15"" align=""center"" style="""& EstiloDeLaCeldaPaginaConLink &"""><a href="""& PaginaActualBarraDeNavegacion & "?pagina=" & i & MisCondiciones & """ class="""  & LinkDelEnlace &  """>" & i & "</a></td>"
  47. else
  48. TablaConBarraDeNavegacion = TablaConBarraDeNavegacion & "<td width=""15"" align=""center"" style="""& EstiloDeLaCeldaPaginaActual &""">" & i & "</td>"
  49. end if
  50. next
  51. else
  52. For i = 1 to 5
  53. if i <> PaginaActual then
  54. TablaConBarraDeNavegacion = TablaConBarraDeNavegacion & "<td width=""15"" align=""center"" style="""& EstiloDeLaCeldaPaginaConLink &"""><a href="""& PaginaActualBarraDeNavegacion & "?pagina=" & i & MisCondiciones &""" class=""" & LinkDelEnlace &  """>" & i & "</a></td>"
  55. else
  56. TablaConBarraDeNavegacion = TablaConBarraDeNavegacion & "<td width=""15"" align=""center"" style="""& EstiloDeLaCeldaPaginaActual &""">" & i & "</td>"
  57. end if
  58. next
  59. end if
  60. end if
  61.  
  62. if MostrarUltima = true then TablaConBarraDeNavegacion = TablaConBarraDeNavegacion & "<td style="""& EstiloDeLaCeldaPaginaConLink &"""><a href="""& PaginaActualBarraDeNavegacion & "?pagina="  & PaginasTotales & MisCondiciones &""" class=""" &  LinkDelEnlace &  """>&Uacute;ltima <strong>»</strong></a></td>"
  63. TablaConBarraDeNavegacion = TablaConBarraDeNavegacion & "</tr></table>"
  64. BarraDeNavegacion = TablaConBarraDeNavegacion
  65. end if
  66. end Function
  67.  
  68. Dim Cnn, RS, SQLQuery1
  69. Dim PaginaActual ' en qué pagina estamos
  70. Dim PaginasTotales ' cuántas páginas tenemos
  71. Dim TamPagina ' cuantos registros por pagina
  72. Dim CuantosRegistros ' para imprimir solo el nº de registro por pagina que queramos
  73.  
  74. TamPagina = 13
  75.  
  76. dim dbCnn
  77.  
  78.       'aca recibo los campos que voy a realizar la busqueda
  79.        
  80.        
  81.    
  82.     On Error Resume next
  83.  
  84.  
  85. 'Leemos qué página mostrar. La primera vez será la inicial
  86. if Request.Querystring( "pagina" ) = "" then
  87. PaginaActual = 1
  88. else
  89. PaginaActual = CInt(Request.Querystring( "pagina" ))
  90. end if
  91.  
  92. codigo = Request("codigo")
  93. familia = Request("familia")
  94. descrip = Request("descrip1")
  95. stock = Request("stock")
  96.  
  97. if Not IsEmpty(Request.Form("codigo")) then
  98. codigo = Request.Form("codigo")
  99. end if
  100.  
  101. if Not IsEmpty(Request.Form("familia")) then
  102. familia = Request.Form("familia")
  103. end if
  104.  
  105. if Not IsEmpty(Request.Form("descrip1")) then
  106. descrip =Request.Form("descrip1")
  107. end if
  108.  
  109. if Not IsEmpty(Request.Form("stock")) then
  110.         stock = replace(Request.Form("stock")," ","_" )
  111. end if
  112.  
  113. Set Cnn = Server.CreateObject( "ADODB.Connection" )
  114. Set rs = Server.CreateObject( "ADODB.Recordset" )
  115. Cnn.Open Session("cnx")
  116.  
  117. strSQL1= "select CODI_FAMILIA from FAMILIAS where  FAMILIA = '"&familia&"' "
  118. set rs1 = Cnn.Execute(strSQL1)
  119.  
  120. If Not rs1.EOF then
  121. codi_fami = rs1.fields ("CODI_FAMILIA")
  122. end if
  123.  
  124. strSQL6= "select substring ('"&codigo&"', 2,2) as codigo_familia "
  125. set rs6 = Cnn.Execute(strSQL6)
  126.  
  127.  
  128. strSQL = " select codprod,descrip,costo,stock from PRODUCTO "
  129.         se_encuentra = False
  130.        
  131.        
  132.        
  133.          if stock = "Solo_con_Stock" then
  134.          if se_encuentra then
  135.     strSQL=strSQL & " AND stock > 0"
  136.             else
  137.        
  138.         strSQL=strSQL & " WHERE  stock > 0"
  139.  
  140.           se_encuentra=True
  141.                      end if
  142.                      end if
  143.                    
  144.        
  145.         if stock = "Sin_Stock" then
  146.          if se_encuentra then
  147.     strSQL=strSQL & " AND stock = 0"
  148.             else
  149.        
  150.         strSQL=strSQL & " WHERE  stock = 0"
  151.  
  152.           se_encuentra=True
  153.                      end if
  154.                      end if
  155.        
  156.        
  157.        
  158.         if codi_fami <> "" then
  159.               if se_encuentra then
  160.     strSQL=strSQL & " AND substring (codprod, 2,2)='"&codi_fami&"'"
  161.         else
  162.         strSQL=strSQL & " where substring (codprod, 2,2)='"&codi_fami&"'"
  163.           se_encuentra=True
  164.                      end if
  165.                      end if
  166.        
  167.        
  168.        
  169.           if codigo <> "" then
  170.               if se_encuentra then
  171.     strSQL=strSQL & " AND codprod LIKE '%"&codigo&"'"
  172.         else
  173.         strSQL=strSQL & " WHERE codprod LIKE '%"&codigo&"'"
  174.           se_encuentra=True
  175.                      end if
  176.                      end if
  177.        
  178.        
  179.         if descrip <> "" then
  180.               if se_encuentra then
  181.     strSQL=strSQL & " AND descrip LIKE '"&descrip&"%'"
  182.         else
  183.         strSQL=strSQL & " WHERE descrip LIKE '"&descrip&"%'"
  184.           se_encuentra=True
  185.                      end if
  186.                      end if
  187.  
  188.        
  189.         ' Defino el tamaño de las páginas
  190. RS.PageSize = TamPagina
  191. RS.CacheSize = TamPagina
  192.  
  193. ' Abro el recordset
  194. RS.Open strSQL, Cnn, 1, 1
  195.  
  196. 'Cuento las páginas
  197. PaginasTotales = Rs.PageCount
  198.  
  199. 'Compruebo que la pagina actual está en el rango
  200. if PaginaActual < 1 then
  201. PaginaActual = 1
  202. end if
  203. if PaginaActual > PaginasTotales then
  204. PaginaActual = PaginasTotales
  205. end if
  206.        
  207.        
  208.        
  209.        
  210.         if PaginasTotales = 0 then
  211.         Response.Redirect("../error/no_search.asp")
  212.        
  213.         ELSE
  214.          session("codigo") = rs.fields ("CODPROD")
  215.         'Vamos a paginar
  216. Rs.AbsolutePage = PaginaActual
  217.  
  218.  
  219. %>
  220.  
  221.  
  222.  
  223. <html>
  224. <head>
  225. <script src="sorttable.js"></script>
  226. <title>Resultado Busqueda</title>
  227. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  228. <style type="text/css">
  229. <!--
  230. body {
  231.     background-image: url(../images/01182_glassorbs_1024x768.jpg);
  232. }
  233. a:link {
  234.     color: #000000;
  235. }
  236. a:visited {
  237.     color: #000000;
  238. }
  239. body,td,th {
  240.     color: #FFFFFF;
  241. }
  242. -->
  243. </style></head>
  244.  
  245. <body>
  246.  
  247.  
  248. <p align="center">
  249. <font face="Bookman Old Style"><em>N&uacute;mero de Repuestos Encontrados:</em></font> <b><%=RS.RecordCount%></b>
  250. <p align="left"><%=BarraDeNavegacion(PaginasTotales, PaginaActual, MisCondiciones)%>
  251. <div align="center">
  252.   <table class="sortable" width="834" height="71" border="1" cellpadding="2" cellspacing="2">
  253.       <tr>
  254.       <td height="39"> Código </td>
  255.       <td> Descripcion: </td>
  256.      <td> Precio: </td>
  257.         <td> Stock: </td>
  258.       </tr>
  259.      
  260.      <%
  261. CuantosRegistros = 0
  262. Do while not RS.EOF and CuantosRegistros < TamPagina
  263. i = i + 1
  264. %>
  265.       <tr>
  266.    
  267.    
  268.    
  269.    
  270.  <td width="243" height="26" >
  271.  <ahref="../pir.asp?codigo=<%=RS.Fields("codprod")%>"><%=RS.Fields("codprod")%>
  272.    
  273.  
  274.    </td>
  275.   <td width="571"><%=RS.Fields("descrip")%></td>
  276.   <td width="571"><%if session("codigo") <>0 then%> <%=formatCurrency(rs.fields("COSTO"),0) %><%end if%></td>
  277.   <td width="571"><%=RS.Fields("STOCK")%></td>
  278.  
  279.  
  280.       </tr>
  281.     <%
  282. CuantosRegistros = CuantosRegistros + 1
  283. RS.MoveNext
  284. loop
  285. %>
  286.   </table>
  287.    
  288.   <div align="left">
  289.     <%
  290. end if
  291.  
  292. RS.Close
  293. Cnn.Close
  294. set RS = nothing
  295. set Cnn = nothing
  296.  
  297. %>
  298.  
  299.   </div>
  300. </div>
  301. </body>
  302. </html>

Me entiendes ahora ??
Que me recomiendas hacer??
De antemano muchas gracias y Saludos..