Visualizzazione dei risultati da 1 a 3 su 3
  1. #1
    Utente di HTML.it
    Registrato dal
    Oct 2004
    Messaggi
    195

    Evidenziare parole cercate in asp

    Come si potrebbero evidenziare, mettere in risalto le parole dei risultati cercati grazie ad Asp e Access?

  2. #2
    fa' una replace aggiungendo i tag ...

  3. #3
    Utente di HTML.it
    Registrato dal
    Oct 2004
    Messaggi
    195
    E dove,come lo dovrei piazzare?!

    Questo è il codice:

    <%@LANGUAGE = JScript%>
    <%

    Response.Buffer = true;
    var Cn = new ActiveXObject("ADODB.Connection");
    Cn.Open("driver={Microsoft Access Driver (*.mdb)};dbq=" + Server.MapPath("XXXXXXXXXXXXXXX"));
    var testo = new String(Server.HTMLEncode(Request.Form("string")));
    var r_testo = testo.replace(/'/g,"''");
    var cerca = r_testo.split(" ");
    var sql = "SELECT * FROM Announcements WHERE ";
    for (var i=0; i<cerca.length; i++)
    {
    if (i > 0) sql += " AND";
    sql += " Obj LIKE '%" + cerca[i] + "%' OR Description LIKE '%" + cerca[i] + "%' OR Genr LIKE '%" + cerca[i] + "%' OR Price LIKE '%" + cerca[i] + "%'";
    }
    sql += " ORDER BY Price";
    var Mostra = Cn.Execute(sql);
    %>
    <html>
    <head>
    </head>
    <body>
    <form method="POST" value="<%cerca != "undefined" ? Response.Write(testo) : Response.Write("")%>">
    <p align="center">
    <input type="text" name="string" size="50" value="<%=testo%>">
    <input type="submit" value="Search" name="B1"></p>
    </form></p>
    <%if (testo != "undefined") {%>
    <%
    if (testo == "" || testo == "undefined" || testo.charAt(0) == " ")
    {
    }
    else if (Mostra.EOF)
    {
    Response.Write("<p align='center'>No result for<font color='#FF0000'> " + testo + "</font></p>");
    }
    else
    {
    while (!Mostra.EOF)
    {
    with (Response)
    {
    %>
    <div align="center">
    <table border="0" cellpadding="0" cellspacing="0" width="100%" id="table1">
    <tr>
    <td>
    <font color="#3778FF"><%=Mostra("Obj")%> - <%=Mostra("Price")%></font>

    </p>
    <%=Mostra("Description")%></font>

    </p>
    ">[img]email.gif[/img]
    <hr style="border: 2px dotted #C0C0C0"></td>
    </tr>
    </table>
    </div>
    <%
    }
    Mostra.MoveNext();
    }
    }
    %>
    <%}%>
    </body>
    </html>
    <%Cn.Close()%>

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.