Tema: Ajax con ASP
Ver Mensaje Individual
  #33 (permalink)  
Antiguo 04/01/2010, 15:27
darkmcloud
 
Fecha de Ingreso: octubre-2007
Mensajes: 191
Antigüedad: 17 años, 6 meses
Puntos: 0
Respuesta: Ajax con ASP

SelecUsuarios.asp

Código ASP:
Ver original
  1. <%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
  2. <%' Option Explicit %>
  3. <% Response.Buffer=True %>
  4. <% On Error Resume Next  %>
  5. <%Response.charset="utf-8"%>
  6. <%
  7. Response.addHeader "pragma", "no-cache"
  8. Response.CacheControl = "Private"
  9. Response.Expires = -1000
  10. %>
  11. <%
  12. Dim SQL, rs, oConn, registros, i
  13. Dim usuario
  14. Dim nombre
  15. nombre = 0
  16. Dim familia
  17. familia = ""
  18.  
  19. usuario = CStr(Request.QueryString("q"))
  20. combox = CStr(Request.QueryString("variable"))
  21.  
  22. IF Len(usuario) >= 2 then
  23. set Cnn = Server.CreateObject("ADODB.Connection")
  24. set rs = Server.CreateObject ("ADODB.Recordset")
  25. Cnn.Open Session("cnx")
  26.  
  27. SQL="select descrip, familia from producto inner join familias on codi_fami = codi_familia "
  28.  
  29.     se_encuentra = False
  30.        
  31.      if combox = "constock" then
  32.             if se_encuentra then
  33.             SQL=SQL & " AND stock > 0"
  34.                 else
  35.             SQL=SQL & "WHERE stock > 0"
  36.             se_encuentra=True
  37.                   end if
  38.                 end if
  39.                    
  40.         if combox = "sinstock" then
  41.             if se_encuentra then
  42.             SQL=SQL & " AND stock = 0"
  43.                 else
  44.             SQL=SQL & "WHERE  stock = 0"
  45.           se_encuentra=True
  46.                   end if
  47.                     end if
  48.                    
  49.             if usuario <> "" then
  50.               if se_encuentra then
  51.     SQL=SQL & " AND descrip LIKE '"&usuario&"%'"
  52.         else
  53.         SQL=SQL & " WHERE descrip LIKE '"&usuario&"%'"
  54.           se_encuentra=True
  55.                      end if
  56.             end if
  57.  
  58. set rs = Cnn.Execute(SQL)
  59.         If not rs.eof then
  60.         registros = rs.getrows()
  61.         familia = rs.Fields("familia")
  62.             Else
  63.             Response.Write "<p class=""deseleccionado""><strong>Sin resultados</strong></p>"
  64.             Response.End ()
  65.         End If
  66.     rs.Close
  67.     set rs = nothing
  68.     Cnn.Close
  69.     set Cnn = nothing
  70. END IF
  71.  
  72. For i = 0 to Ubound(registros,2)
  73. If i = 0 then
  74. Response.Write "<div id="""& registros(nombre,i) &""" class=""seleccionado"">"& ResaltarSubStr(registros(nombre,i)) & "</div>"
  75. Else
  76. Response.Write "<div id="""& registros(nombre,i) &""" class="""">" & ResaltarSubStr(registros(nombre,i)) & "</div>"
  77. End If
  78. Next
  79.  
  80. ' ========= Funciones ===========
  81. Function ResaltarSubStr(texto)
  82. Dim objRegExp
  83.  
  84.     Set objRegExp= New RegExp
  85. objRegExp.IgnoreCase = True
  86. 'objRegExp.Global = True
  87.  
  88. objRegExp.Pattern = "\b("&usuario&")+(\w)"
  89. texto = objRegExp.Replace(texto, "<strong>$1</strong>$2")
  90.  
  91.     Set objRegExp = Nothing
  92.  
  93.     ResaltarSubStr = texto
  94.  
  95. End Function
  96. ' ========= Fin Funciones ===========
  97. %>

Tuve que hacerlo en 2 post puesto que el foro reclamaba por texto muy largo...jejejee

Aps... cambie un poco la consulta en SelecUsuarios.asp...pero funciona bien solo es para hacer una consulta de más campos a futuro...jejejeje

Esop.... nuevamente graxxx