Ver Mensaje Individual
  #1 (permalink)  
Antiguo 10/03/2010, 17:13
glory82
 
Fecha de Ingreso: febrero-2007
Mensajes: 139
Antigüedad: 17 años, 2 meses
Puntos: 0
Crear checkbox automatica/. con nombres diferentes

Hola a todos,

Les escribo porque tengo un problema con un checkbox que se crea automaticamente:

Tengo una pagina la cual me crea checkbox en una tabla de acuerdo al resultado de una consulta en la base de datos.
Ejm. Si hay 5 datos, crea 5 checkbox. El usuario obviamente puede chulear varios checkbox.

Cada checkbox es una variable de la BD y yo le voy asignando un numero en un for, para distinguir uno de otro.El problema es que el checkbox siempre se llama igual (input name="C1") pero su value es diferente, Por lo que el "request.ServerVariables" me muestra que el checkbox tiene varios valores.
Adjunto codigo de lo que pasa.

Como hago para colocarle diferentes nombres al checkbox que se vaya creando?

Muchas gracias a quien me pueda colaborar.
Código HTML:
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office">
<head>
<title>Adicionar Filtracion</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<form name="form1" method="post" action="">
<p align="center"><strong><font color="#006633">Seleccione el Tanque/Tonel a 
filtrar, luego ingrese los datos y clic en Grabar</font></strong></p>
<%
Dim Tabla(100,5)    
Dim BuscaDatos
Set BuscaDatos= Server.CreateObject("ADODB.Recordset")
BuscaDatos.ActiveConnection = MM_ElabCavas_STRING
BuscaDatos.Source = "SELECT * FROM dbo.Filtracion WHERE Fechainicio is null order by lotemadurac  "
BuscaDatos.CursorType = 0
BuscaDatos.CursorLocation = 2
BuscaDatos.LockType = 1
BuscaDatos.Open()

if (Not BuscaDatos.eof) then%>
	<table border="1" style="width: 347px" align="center">
      <tr>
        <td colspan="3" class="style8" style="height: 26px"><strong>Seleccione el Tanque/Tonel a Filtrar</strong></td>
      </tr>
      <tr>
          <td class="style11" style="width: 6728px; height: 21px;"><strong>Lote</strong></td>
          <td class="style8" style="height: 21px; width: 3653px;"><strong>Tanque/Tonel</strong></td>
          <td class="style8" style="width: 3500px; height: 21px;"><strong>Producto</strong></td>
      </tr>
	<%BuscaDatos.movefirst()   
    i=0
    Dim NombrePcto,NombreCubaTanque,TkTonel,Pcto
    Do while (Not BuscaDatos.eof) 
       	Tabla(i,0) 	= BuscaDatos.fields.item("LoteMadurac").value
        TkTonel		= BuscaDatos.fields.item("TkTonel").value
        Pcto		= BuscaDatos.fields.item("Producto").value
   		BuscaNombreCT
		tabla(i,1) 	= NombreCubaTanque
		tabla(i,2) 	= NombrePcto
        i=i+1
        BuscaDatos.movenext()  
    Loop
    Final = i-1
    for i = 0 to final%>
       <tr>
         <td class="style10" style="width: 6728px">
         <input name="C1" type="checkbox" value="<%=i%>"><span class="style42"><span class="style3"><%Response.write "&nbsp;"%><%Response.write Tabla (i,0)%><font face="Arial"></font></span></span></td>
         <td class="style9" style="width: 3653px"><%Response.write Tabla (i,1)%></td>
         <td class="style9" style="width: 3500px"><%Response.write Tabla (i,2)%></td>
        </tr>
        <%tabla (i,3) = i
     next%>
    </table>
<%end if
Session("S_Tabla") = Tabla
Session("S_final") = final
BuscaDatos.Close()
Set BuscaDatos= Nothing%>
<br>
  <p align="center"> 
    <input type="submit" name="GRABAR" value="GRABAR">
  </p>
</form>
<p align="center">&nbsp;</p>
<%
'ADQUIERE LOS VALORES INGRESADOS POR EL USUARIO PARA LLENAR LA TABLA
IF request.form("GRABAR") = "GRABAR" then
	Dim LoteFiltracion(100)
	if request.ServerVariables("REQUEST_METHOD")="POST" then
		for each control in request.form
			response.write control & " = " & request.form(control)&"<br>"
			if control= "checkbox" then
				opcion = request.form(control)
			end if
	    next
	end if		
END IF%>
</body>
</html>