Visualizzazione dei risultati da 1 a 3 su 3
  1. #1

    Variabile ID al link dei risultati

    Sto cercando di aggiungere al link del risultato della ricerca anche l'ID del prodotto per poterlo passare come variabile ma non ci riesco!

    ----> href='ModCons.asp?id=Rec('id')'

    codice:
    <%@LANGUAGE = JScript%>
    <%
    	Response.Buffer = true;
    	var Cn = new ActiveXObject("ADODB.Connection");
    		Cn.Open("driver={Microsoft Access Driver (*.mdb)};dbq=" + Server.MapPath("/mdb-database/circuiti.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 consuntivo WHERE ";
    		for (var i=0; i<cerca.length; i++)
    		{
    			if (i > 0) sql += " AND";
    			sql += " codice LIKE '%" + cerca[i] + "%'";
    		}
    		sql += " ORDER BY data";
    	var Mostra = Cn.Execute(sql);
    %>
    <html>
    <head>
    <title>Cerca</title>
    <link href="style.css" rel="stylesheet" type="text/css">
    </head>
    <body>
    <b class="titoli">Cerca[/b]
    	<form method="post" action="cerca.asp">
    		<input type="text" name="cerca" size="50" value="<%cerca != "undefined" ? Response.Write(testo) : Response.Write("")%>">
    		<input type="submit" value="Cerca">
    	</form>
    <%if (testo != "undefined") {%>
    
    
    Risultati della ricerca per il termine <font color="Red"><%=testo%></font></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("descrizione") + "
    ");
    			Write(Mostra("descrizione") + "
    ");
    			Write("" + Mostra("cliente") + "");
    			Write("</p>");
    			}
    			Mostra.MoveNext();
    		}
    	}
    %>
    <%}%>
    </body>
    </html>
    <%Cn.Close()%>

  2. #2
    Utente di HTML.it L'avatar di willybit
    Registrato dal
    May 2001
    Messaggi
    4,367
    e cosa sarebbe Rec('id')???

    non è che devi fare così?
    codice:
    Write("<a href=\"ModCons.asp?id=" + Mostra("id") + "&cliente=" + Mostra("cliente") + "\" target=\"_blank\">" + Mostra("descrizione") + "</a>
    ");

  3. #3
    Grazie andava benissimo ma mi stampa un NULL non capisco da dove lo tira fuori visto che i due campi "cliente" e codice" non sono vuoti...!

    RT SWITCHnull PAOLA
    RT SWITCHnull PAOLA
    RT SWITCHnull PAOLA

    codice:
          <%
    	if (testo == "" || testo == "undefined" || testo.charAt(0) == " ")
    	{
    		Response.Write("Inserire un codice per effettuare una ricerca");
    	}
    	else if (Mostra.EOF)
    	{
    		Response.Write("Nessun risultato");
    	}
    	else
    	{
    		while (!Mostra.EOF)
    		{
    			with (Response)
    			{
    			Write("<a href=\"default.asp?id=" + Mostra("id") + "&cliente=" + Mostra("esecutore") + "\" target=\"_self\">" + Mostra("descrizione") + "</a>");
    			Write(Mostra("descrizione") + "");
    			Write("" + Mostra("esecutore") + "
    
    ");
    			}
    			Mostra.MoveNext();
    		}
    	}
    %>
          <%}%>

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.