Ver Mensaje Individual
  #10 (permalink)  
Antiguo 19/07/2010, 14:11
luisosorio
 
Fecha de Ingreso: julio-2010
Mensajes: 2
Antigüedad: 13 años, 9 meses
Puntos: 0
Respuesta: Jquery + pasar multiple Checkbox

Que tal Dany_s creo que sergi_climent no utilizo serialize porque al usar tu ejemplo que pusiste anteriormente el resultado seria:

preventiu=1&preventiu=2&preventiu=3&preventiu=4&pr eventiu=5&preventiu=6&preventiu=7

Ahora bien como tu dices que se muestra como en los formularios que se manda la informacion por get tienes razon pero si vez el valor de cada uno es la misma variable que es preventiu.
Entonces lo que puede hacer sergi_climent para que le salga el codigo mejor es utilizar serialize de la siguiente manera

$( function (){
$('input:checkbox').change( function (){
$('#campos').text( $('input:checkbox').serialize() );
});
});

Con esto sergi_climent podra tener los checkbox de diferentes nombres y las variables se presentarian distintas. Un ejemplo sencillo:

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Prueba</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script>
$( function (){
$('input:checkbox').change( function (){
$('#campos').text( $('input:checkbox').serialize() );
});
});
</script>
</head>
<body>
<input type="checkbox" name="preventiu1" value="1"><br />
<input type="checkbox" name="preventiu2" value="2"><br />
<input type="checkbox" name="preventiu3" value="3"><br />
<input type="checkbox" name="preventiu4" value="4"><br />
<input type="checkbox" name="preventiu5" value="5"><br />
<input type="checkbox" name="preventiu6" value="6"><br />
<input type="checkbox" name="preventiu7" value="7"><br />
<div id="campos"></div>
</body>
</html>

La data se motraría así:

preventiu1=1&preventiu2=2&preventiu3=3&preventiu4= 4&preventiu5=5&preventiu6=6&preventiu7=7