Salve ragazzi devo impaginare i risultati di una ricerca e girando sul forum ho trovato le risposte che cercavo.
In partica io inserisco dei termini in un campo all'interno di un form e poi mi vengono restituiti dei risultati.
Ho fatto in questo modo ma mi restituiesce il seguente errore:
codice:Microsoft JScript compilation error '800a03f7' Unterminated string constant /nuovaGraficaProdotti.asp, line 208 numero=5 'notizie per pagina
Questo è il codice della pagina e in rosso evidenzio ciò che ho aggiunto io. (E' solo la parte interessata)
Potreste portarmi sulla strada giusta per capire l'errore da cosa dipende?codice:<%@LANGUAGE = JScript%> <head> <% Response.Buffer = true; var Cn = new ActiveXObject("ADODB.Connection"); Cn.Open("driver={Microsoft Access Driver (*.mdb)};dbq=" + Server.MapPath("database/sial.mdb")); var testo = new String(Server.HTMLEncode(Request.Form("cerca"))); var r_testo = testo.replace(/'/g,"''"); var cerca = r_testo.split(" "); // Tutte le parole chiave devono essere separate da uno spazio vuoto var sql = "SELECT * FROM Prodotti WHERE "; for (var i=0; i<cerca.length; i++) { if (i > 0) sql += " AND"; sql+= " CodiceProdotto LIKE '%" + cerca[i] + "%' or Prodotto LIKE '%" + cerca[i] + "%'"; } sql += " ORDER BY Categoria"; var Mostra = Cn.Execute(sql); %> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Documento senza titolo</title> <link href="css/sial.css" rel="stylesheet" type="text/css" /> <style type="text/css"> <!-- body { margin-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; background-color: #666666; } --> body { font: .80em verdana, helvetica, sans-serif; } ul { list-style: disc url(doc.gif); margin:0;padding:0 2em; } li.menu { list-style: square url(cartellachiusa.gif); } --> </style> <script type="text/javascript"> <!-- function mmenu(mID) { var menu = document.getElementById(mID); var display = menu.style.display; menu.style.display = (display == "block") ? "none" : "block"; menu.parentNode.style.listStyleImage = (display == "block") ? "url(cartellachiusa.gif)" : "url(cartellaaperta.gif)"; } window.onload = function() { var uls = document.getElementsByTagName("ul"); for (i=0;i<uls.length;i++) { if(uls[i].className=="submenu")uls[i].style.display = "none"; } } //--> </script> </head> <body> <td class="testo"> <form method="post" action="nuovaGraficaProdotti.asp"> <input type="text" name="cerca" size="20" value="<%cerca != "undefined" ? Response.Write(testo) : Response.Write("")%>"> <input type="submit" value="Cerca"> </form> </td> </tr> <tr> <td class="testo">[img]Images/px1.gif[/img]</td> </tr> <tr> <td align="center" class="testo">[img]images/unieniso.jpg[/img]</td> </tr> </table></td> <td width="10" valign="top" class="lineaDivisoria"></td> <td width="500" valign="top"><table width="500" height="10" border="0" cellpadding="0" cellspacing="0"> <tr> <td><span class="testo">[img]Images/px1.gif[/img]</span></td> </tr> <tr> <td><table width="500" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="10" valign="top">[img]Images/px1.gif[/img]</td> <td valign="top"><table width="490" border="0" cellspacing="0" cellpadding="0"> <tr align="left"> <td class="titoliniPagina"> .:: Prodotti ::.</p> </td> </tr> <tr> <td><span class="testo">[img]Images/px1.gif[/img]</span></td> </tr> <tr align="left"> <td>[img]prodotti/pipette.jpg[/img]</td> </tr> <tr> <td><span class="testo">[img]Images/px1.gif[/img]</span></td> </tr> <tr> <td align="left" valign="top" class="testo"><%if (testo != "undefined") {%> Risultati della ricerca per il termine <font color="Red"><%=testo%></font> <% numero=5 'notizie per pagina controllo=numero pag = TRIM(Request.Form("cerca")) 'paginazione If cerca="" Then cerca = 1 Else cerca = CInt(cerca) End If %> </p> <% if (testo == "" || testo == "undefined" || testo.charAt(0) == " ") { Response.Write(" Inserire un termine per effettuare una ricerca</p>"); } else if (Mostra.EOF) { Response.Write(" Nessun risultato</p>"); } else { while (!Mostra.EOF) { with (Response) { Write(" "); Write(Mostra("CodiceProdotto") + " "); Write(Mostra("Prodotto") + " "); Write("</p>"); } Mostra.MoveNext(); } } %> <%}%> </p></td> </tr> <tr> <td align="center" valign="top" class="testo"> <table width="250" border="0" cellspacing="0" cellpadding="0"> <tr> <td align="center"><% if tot mod(numero)=0 then lastpage=int(tot/numero) else 'deve numerare l'ultima pagina anche se incompleta! lastpage=int(tot/numero)+1 end if for c=1 to lastpage %> | <%=c%> <% next %></td> </tr> <tr> <td align="center" class="testo">Pag. <%=cerca%> di <%=lastpage%></td> </tr> </table> </td> </tr> <tr> <td align="left" valign="top" class="testo"> </td> </tr> <tr> <td align="left" valign="top" class="testo"> </td> </tr> <tr> <td align="left" valign="top" class="testo"></td> </tr> </table></td> </tr> </table></td> </tr> </table></td> </tr> </table></td> </tr> </table></td> <td width="5" bgcolor="#FFFFFF">[img]images/px1.gif[/img]</td> </tr> <tr bgcolor="#FFFFFF"> <td colspan="3" bgcolor="#FFFFFF"><span class="testo">[img]Images/px1.gif[/img]</span></td> </tr> <tr bgcolor="#FFFFFF"> <td bgcolor="#FFFFFF"></td> <td align="center" valign="top" class="testoFooter">Copyright ©2006 Sial Group - Partita IVA 00959981002 - Via Giovanni Devoti, n.14 - 00168 Roma - E-Mail: info@sialgroup.com </td> <td bgcolor="#FFFFFF"></td> </tr> </table> </td> </tr> </table> </body> </html> <%Cn.Close()%>
grazie
![]()

Rispondi quotando