Buscador de productos
Mira este fragmento de código de una página que crea un recordset a una tabla de una tabla de una base de datos y vuelva el contenido en un combobox, poniendo como valor el código único (autonumérico) del cliente CLI_ID y muestra el nombre CLI_NOM. Al elegir alguno automatiamente, mediante la función sltar en javascript va a la página a_facturas_ventas.asp pasándole el código del cliente. Te puede servir para adaptarlo a tu entorno de productos:
<%@LANGUAGE="VBSCRIPT"%>
<!--#include file="Connections/conex_usr.asp" -->
<%
Dim cliente
Set cliente = Server.CreateObject("ADODB.Recordset")
cliente.ActiveConnection = con_usr
cliente.Source = "SELECT * FROM CLIENTES ORDER BY CLI_NOM"
cliente.CursorType = 0
cliente.CursorLocation = 2
cliente.LockType = 1
cliente.Open()
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>> Departamento de Administración > Búsqueda de Clientes/Proveedores para creación de Facturas</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="hoja.css" rel="stylesheet" type="text/css">
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_jumpMenu(targ,selObj,restore){ //v3.0
eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
if (restore) selObj.selectedIndex=0;
}
function saltar(pag,selObj){
if (selObj.selectedIndex!=0) {
eval("location.href='"+pag+"?id="+selObj.options[selObj.selectedIndex].value+"'");
}
}
//-->
</script>
</head>
<body leftmargin="0" topmargin="0">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr class="cuerpo1small">
<td width="17%"><img src="images/puntoazul.gif" width="7" height="7"> Seleccione
Cliente</td>
<td width="52%"><font color="#000000">
<select name="client" class="cuerpo1small" id="select2" onChange="saltar('a_facturas_ventas.asp',this)">
<option value="0" selected>Seleccione un Cliente de la Lista</option>
<%
While (NOT cliente.EOF)
%>
<option value="<%=(cliente.Fields.Item("CLI_ID").Value)%>"><%=(cliente.Fields.Item("CLI_NOM").Value)%></option>
<%
cliente.MoveNext()
Wend
If (cliente.CursorType > 0) Then
cliente.MoveFirst
Else
cliente.Requery
End If
%>
</select>
</font></td>
</tr>
</table>
</body>
</html>
Espero te sirva para comprender como funciona.
Un saludo dsd Cádiz
<%@LANGUAGE="VBSCRIPT"%>
<!--#include file="Connections/conex_usr.asp" -->
<%
Dim cliente
Set cliente = Server.CreateObject("ADODB.Recordset")
cliente.ActiveConnection = con_usr
cliente.Source = "SELECT * FROM CLIENTES ORDER BY CLI_NOM"
cliente.CursorType = 0
cliente.CursorLocation = 2
cliente.LockType = 1
cliente.Open()
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>> Departamento de Administración > Búsqueda de Clientes/Proveedores para creación de Facturas</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="hoja.css" rel="stylesheet" type="text/css">
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_jumpMenu(targ,selObj,restore){ //v3.0
eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
if (restore) selObj.selectedIndex=0;
}
function saltar(pag,selObj){
if (selObj.selectedIndex!=0) {
eval("location.href='"+pag+"?id="+selObj.options[selObj.selectedIndex].value+"'");
}
}
//-->
</script>
</head>
<body leftmargin="0" topmargin="0">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr class="cuerpo1small">
<td width="17%"><img src="images/puntoazul.gif" width="7" height="7"> Seleccione
Cliente</td>
<td width="52%"><font color="#000000">
<select name="client" class="cuerpo1small" id="select2" onChange="saltar('a_facturas_ventas.asp',this)">
<option value="0" selected>Seleccione un Cliente de la Lista</option>
<%
While (NOT cliente.EOF)
%>
<option value="<%=(cliente.Fields.Item("CLI_ID").Value)%>"><%=(cliente.Fields.Item("CLI_NOM").Value)%></option>
<%
cliente.MoveNext()
Wend
If (cliente.CursorType > 0) Then
cliente.MoveFirst
Else
cliente.Requery
End If
%>
</select>
</font></td>
</tr>
</table>
</body>
</html>
Espero te sirva para comprender como funciona.
Un saludo dsd Cádiz
1 respuesta
Respuesta de averias33
1