Foros del Web » Programando para Internet » Javascript »

como obtener value de checkbox

Estas en el tema de como obtener value de checkbox en el foro de Javascript en Foros del Web. Hola!!.. queria saber como se hace para obtener el value de un checkbox ?.. Código HTML: <html> <head> <script type='text/javascript'> var checkboxes = document.getElementById("tabla2").home; for ...
  #1 (permalink)  
Antiguo 02/06/2011, 19:39
Avatar de juan_14nob  
Fecha de Ingreso: abril-2010
Mensajes: 552
Antigüedad: 14 años
Puntos: 6
como obtener value de checkbox

Hola!!.. queria saber como se hace para obtener el value de un checkbox ?..

Código HTML:
<html>
<head>
<script type='text/javascript'>
var checkboxes = document.getElementById("tabla2").home;

    for (var x=0; x < checkboxes.length; x++){
    if (checkboxes[x].checked){


    }else{
	alert("Seleccione al menos 1 registro..");
	break;
	}
	
    }

</script>
</head>
<body>
<form name="tabla2" method="POST">
<input type='checkbox' name='home' value='1'>
<input type='button' value='Aceptar' onclick='cargar();'>
</form>
</body>
</html> 
  #2 (permalink)  
Antiguo 02/06/2011, 20:38
Avatar de livemusic  
Fecha de Ingreso: abril-2011
Ubicación: Lima - Chorrillos
Mensajes: 150
Antigüedad: 13 años
Puntos: 18
Respuesta: como obtener value de checkbox

Espero y te funcione suerte xD....

Cita:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Documento sin título</title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
<script type="text/javascript" language="javascript">
$(document).ready(function(){
$('.check').live('click', function(){
// .attr('checked')
if($(this).is(':checked')){
alert('Check Seleccionado '+this.value);
}
})
})
</script>
</head>

<body>
<table width="200" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="31">&nbsp;</td>
<td width="169"><strong>Nombres</strong></td>
</tr>
<tr>
<td><input type="checkbox" name="nombre" class="check" value="1" /></td>
<td>Antony</td>
</tr>
<tr>
<td><input type="checkbox" name="nombre" class="check" value="2" /></td>
<td>Carolina</td>
</tr>
<tr>
<td><input type="checkbox" name="nombre" class="check" value="3" /></td>
<td>Marisol</td>
</tr>
</table>
</body>
</html>

Etiquetas: checkbox
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 20:55.