Salve,
uso questo script per visualizzare articoli in tempo reale dati da db, solo che me ne carica un per volta
vorrei che mi elencasse e accodasse tutti gli articoli ogni qualvolta inserisco un codice articolo nel campo form codice_articolo.
Il campo codice_articolo deve azzerarsi ogni caricamento.
Naturalmente tutti questi dati saranno salvati al submit del form.
codice:
<script>
function showCustomer(str)
{
if (str=="")
{
document.getElementById("txtHint").innerHTML="";
return;
}
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (this.readyState==4 && this.status==200)
{
document.getElementById("txtHint").innerHTML=this.responseText;
}
}
xmlhttp.open("GET","cerca.asp?q="+str,true);
xmlhttp.send();
}
</script>
<form action="salvadatiform.asp">
<input type="text" name="codice_articolo" size="60" onKeyup="showCustomer(this.value)" >
<div id="txtHint"></div>
<input type="submit" value="Salva form" name="B1">
</form>
PAGINA CERCA.ASP
codice:
<%
sql="SELECT * FROM merce WHERE Cd_AR="
sql=sql & "'" & request.querystring("q") & "'"
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open sql, Conn, 3, 3
if rs.eof then
%>
<p align="center"><font>Nessuno articolo con questo codice</font></p>
<%
else
%>
<table border="1" width="100%" >
<tr>
<td width="156"><b><font>Codice articolo</font></b></td>
<td width="245"><b><font>Descrizione</font></b></td>
<td width="167"><b><font>Quantita'</font></b></td>
</tr>
<%
do while not rs.eof
%>
<tr>
<td width="156"><font><%=rs.fields("Cd_AR")%></font></td>
<td width="245"><font><%=rs.fields("Descrizione")%></font></td>
<td width="167"><font><%=rs.fields("Qta")%></font></td>
</tr>
<input type="hidden" name="Cd_AR" value="<%=rs.fields("Cd_AR")%>">
<input type="hidden" name="Descrizione" value="<%=rs.fields("Descrizione")%>">
<input type="hidden" name="Qta" value="<%=rs.fields("Qta")%>">
<%
rs.MoveNext
loop
rs.Close
end if
%>
</table>
<%
end if
%>
Grazie per l'aiuto