Ver Mensaje Individual
  #1 (permalink)  
Antiguo 08/10/2004, 05:03
Avatar de angel_dope
angel_dope
 
Fecha de Ingreso: noviembre-2002
Ubicación: Valencia
Mensajes: 737
Antigüedad: 21 años, 5 meses
Puntos: 8
No poder seleccionar más de 5 Checkbox

Hola a tod@s, estoy intentando usar este código que he encontrado en las faqs, pero no consigo que funcione. Lo que quiero es que el usuario no pueda seleccionar más de 5 checkbox de un formulario. Este formulario se crea mediante una asp sacando los datos de una base de datos. Os dejo el código que tengo por ahora

Esto está en el head:
Código PHP:
<head>
<
title>Untitled Document</title>
<
script

function 
countChoices(obj) { 
max 5// max. number allowed at a time 

obj.form.PollVote[1].checked// your checkboxes here 
obj.form.PollVote[2].checked// your checkboxes here 
obj.form.PollVote[3].checked// your checkboxes here 
obj.form.PollVote[4].checked// your checkboxes here 
obj.form.PollVote[5].checked// your checkboxes here 


// add more if necessary 

count = (0) + (0) + (0) + (0) + (0); 
// If you have more checkboxes on your form 
// add more (box_ ? 1 : 0) 's separated by '+' 

if (count max) { 
alert("Atencion! Solo puede seleccionar " max " opcion! \Quite una de ellas si quiere seleccionar otra."); 
obj.checked false


</script> 
Y esto es el formulario:
Código PHP:
<form name="form" method="post" action="">
  <
table width="100%" border="1" cellspacing="0" cellpadding="0">
    <
tr
      <
td>&nbsp;</td>
      <
td
        <
div align="center">Marca</div>
      </
td>
      <
td
        <
div align="center">Procesador</div>
      </
td>
      <
td
        <
div align="center">Memoria (Mb)</div>
      </
td>
      <
td
        <
div align="center">Disco Duro (Gb)</div>
      </
td>
      <
td
        <
div align="center">Sistema Operativo</div>
      </
td>
      <
td
        <
div align="center">Monitor</div>
      </
td>
    </
tr>
    <% 
While ((
Repeat1__numRows <> 0) AND (NOT Ordenadores.EOF)) 
%>
    <
tr
      <
td
        <
div align="center"
          <
input type="checkbox" value="1" name="PollVote" onClick="countChoices(this)"
        </
div>
      </
td>
      <
td><%=(Ordenadores.Fields.Item("Marca").Value)%></td>
      <
td><%=(Ordenadores.Fields.Item("Procesador").Value)%></td>
      <
td><%=(Ordenadores.Fields.Item("Memoria").Value)%></td>
      <
td><%=(Ordenadores.Fields.Item("Disco_Duro").Value)%></td>
      <
td><%=(Ordenadores.Fields.Item("Sistema_Operativo").Value)%></td>
      <
td><%=(Ordenadores.Fields.Item("Monitor").Value)%></td>
    </
tr>
    <% 
  
Repeat1__index=Repeat1__index+1
  Repeat1__numRows
=Repeat1__numRows-1
  Ordenadores
.MoveNext()
Wend
%>
  </
table>
</
form
Espero que alguien pueda darme una solución, muchas gracias.

Salu2
__________________
Vayamos por Partes :: Jack el Destripador