mil gracias de nuevo por tu interes, mira te pego todo el codigo entero, limpiado y solo con el formulario y el select, y me sigue haciendo lo mismo, me borra siempre el primero y no el que le pido.
El select es dinamico, ya que coje las referencias del campo "Referencia" de la base de datos y al seleccionar pues el numero de referencia que existe en la base deveria borrar ese registro.
Código:
<%@LANGUAGE="JAVASCRIPT"%>
<!--#include file="Connections/agencia.asp" -->
<%
// *************************** Edit Operations: declare variables
// *************************** set the form action variable
var MM_editAction = Request.ServerVariables("SCRIPT_NAME");
if (Request.QueryString) {
MM_editAction += "?" + Server.HTMLEncode(Request.QueryString);
}
// *************************** boolean to abort record edit
var MM_abortEdit = false;
// *************************** query string to execute
var MM_editQuery = "";
%>
<%
// *************************** Delete Record: declare variables
if (String(Request("MM_delete")) == "formeliminarproducto" &&
String(Request("MM_recordId")) != "undefined") {
var MM_editConnection = MM_agencia_STRING;
var MM_editTable = "productos_venta";
var MM_editColumn = "Referencia";
var MM_recordId = "" + Request.Form("MM_recordId") + "";
var MM_editRedirectUrl = "eliminar_productos2.asp";
// *************************** append the query string to the redirect URL
if (MM_editRedirectUrl && Request.QueryString && Request.QueryString.Count > 0) {
MM_editRedirectUrl += ((MM_editRedirectUrl.indexOf('?') == -1)?"?":"&") + Request.QueryString;
}
}
%>
<%
// *************************** Delete Record: construct a sql delete statement and execute it
if (String(Request("MM_delete")) != "undefined" &&
String(Request("MM_recordId")) != "undefined") {
// *************************** create the sql delete statement
MM_editQuery = "delete from " + MM_editTable + " where " + MM_editColumn + " = " + MM_recordId;
if (!MM_abortEdit) {
// *************************** execute the delete
var MM_editCmd = Server.CreateObject('ADODB.Command');
MM_editCmd.ActiveConnection = MM_editConnection;
MM_editCmd.CommandText = MM_editQuery;
MM_editCmd.Execute();
MM_editCmd.ActiveConnection.Close();
if (MM_editRedirectUrl) {
Response.Redirect(MM_editRedirectUrl);
}
}
}
%>
<%
var eliminar_produc = Server.CreateObject("ADODB.Recordset");
eliminar_produc.ActiveConnection = MM_agencia_STRING;
eliminar_produc.Source = "SELECT * FROM productos_venta";
eliminar_produc.CursorType = 0;
eliminar_produc.CursorLocation = 2;
eliminar_produc.LockType = 1;
eliminar_produc.Open();
var eliminar_produc_numRows = 0;
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Intranet</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="css/css.css" rel="stylesheet" type="text/css">
</head>
<body>
<div align="center">
<table width="740" height="100%" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#BECB94">
<tr>
<td width="79%" colspan="2">
<table width="100%" border="0" cellspacing="0" cellpadding="25">
<tr>
<td><p align="center"> </p>
<form ACTION="<%=MM_editAction%>" METHOD="post" name="formeliminarproducto" id="formeliminarproducto">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="36%"><div align="center">Nº Referencia a eliminar: </div></td>
<td colspan="2"><div align="left">
<select name="Refe" size="1" id="Refe">
<%
while (!eliminar_produc.EOF) {
%>
<option value="<%=(eliminar_produc.Fields.Item("Referencia").Value)%>"><%=(eliminar_produc.Fields.Item("Referencia").Value)%></option>
<%
eliminar_produc.MoveNext();
}
if (eliminar_produc.CursorType > 0) {
if (!eliminar_produc.BOF) eliminar_produc.MoveFirst();
} else {
eliminar_produc.Requery();
}
%>
</select>
</div>
</td>
</tr>
<tr>
<td colspan="3">
<div align="center">
<input name="elimiar_produc" type="submit" id="elimiar_produc" value="Eliminar Producto">
</div>
</td>
</tr>
</table>
<input type="hidden" name="MM_delete" value="formeliminarproducto">
<input type="hidden" name="MM_recordId" value="<%= eliminar_produc.Fields.Item("Referencia").Value %>">
</form><p align="justify"> </p>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</body>
</html>
<%
eliminar_produc.Close();
%>
mil gracias de nuevo y un saludo!!!