<?xml version="1.0" encoding="UTF-8"?><!-- generator="bbPress" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
>
	<channel>
		<title>Dudas de Programacion &#187; Topic: Contar Checkbox</title>
		<link>http://www.dudasprogramacion.com/topic/contar-checkbox</link>
		<description>Dudas sobre lenguajes y apis de programación</description>
		<language>en-US</language>
		<pubDate>Sun, 05 Sep 2010 08:40:58 +0000</pubDate>
		<generator>bbpress 1.0.2</generator>
		<textInput>
			<title><![CDATA[Search]]></title>
			<description><![CDATA[Search all topics from these forums.]]></description>
			<name>q</name>
			<link>http://www.dudasprogramacion.com/search.php</link>
		</textInput>
		<atom:link href="http://www.dudasprogramacion.com/rss/topic/contar-checkbox" rel="self" type="application/rss+xml" />

		<item>
			<title>Torres on "Contar Checkbox"</title>
			<link>http://www.dudasprogramacion.com/topic/contar-checkbox#post-336</link>
			<pubDate>Tue, 09 Mar 2010 11:38:28 +0000</pubDate>
			<dc:creator>Torres</dc:creator>
			<guid isPermaLink="false">336@http://www.dudasprogramacion.com/</guid>
			<description>&#60;p&#62;Buenas!&#60;/p&#62;
&#60;p&#62;Para lo que quieres hacer, necesitas llamar a la función contar() cada vez que se marque un checkbox, para eso puede usar la funcion onClick()o en este caso también onChange() &#60;/p&#62;
&#60;p&#62;&#60;a href=&#34;http://www.w3schools.com/jsref/dom_obj_event.asp&#34; rel=&#34;nofollow&#34;&#62;http://www.w3schools.com/jsref/dom_obj_event.asp&#60;/a&#62;&#60;/p&#62;
&#60;p&#62;También debes cambiar el alert por una linea que modifique el valor de una caja de texto, por ejemplo: document.formulario.nombreCajaTexto.value = cont;&#60;/p&#62;
&#60;p&#62;Te recomiendo que le eches un vistazo a este tutorial del w3c sobre javascript: &#60;a href=&#34;http://www.w3schools.com/JS/&#34; rel=&#34;nofollow&#34;&#62;http://www.w3schools.com/JS/&#60;/a&#62;&#60;/p&#62;
&#60;p&#62;Te mando las modificaciones en el código que mandas para que funcione de la manera que comentas:&#60;/p&#62;
&#60;p&#62;&#38;lt;html&#38;gt;&#60;br /&#62;
&#38;lt;head&#38;gt;&#60;br /&#62;
&#38;lt;title&#38;gt;Cuenta CheckBox&#38;lt;/title&#38;gt;&#60;/p&#62;
&#60;p&#62;&#38;lt;script language=&#38;quot;javascript&#38;quot;&#38;gt;&#60;/p&#62;
&#60;p&#62;function contar() {&#60;/p&#62;
&#60;p&#62;var checkboxes = form1.checkbox; //Array que contiene los checkbox&#60;br /&#62;
var cont = 0; //Variable que lleva la cuenta de los checkbox pulsados&#60;/p&#62;
&#60;p&#62;for (var x=0; x &#38;lt; checkboxes.length; x++) {&#60;br /&#62;
if (checkboxes[x].checked) {&#60;br /&#62;
cont = cont + 1;&#60;br /&#62;
}&#60;br /&#62;
}&#60;/p&#62;
&#60;p&#62;document.form1.cajaTexto.value = cont;&#60;/p&#62;
&#60;p&#62;}&#60;br /&#62;
&#38;lt;/script&#38;gt;&#60;/p&#62;
&#60;p&#62;&#38;lt;/head&#38;gt;&#60;/p&#62;
&#60;p&#62;&#38;lt;body bgcolor=&#38;quot;#FFFFFF&#38;quot; text=&#38;quot;#000000&#38;quot;&#38;gt;&#60;/p&#62;
&#60;p&#62;&#38;lt;form name=&#38;quot;form1&#38;quot; method=&#38;quot;post&#38;quot; action=&#38;quot;&#38;quot;&#38;gt;&#60;br /&#62;
&#38;lt;input type=&#38;quot;checkbox&#38;quot; name=&#38;quot;checkbox&#38;quot; value=&#38;quot;checkbox&#38;quot; onClick=&#38;quot;contar();&#38;quot;&#38;gt;&#60;br /&#62;
CheckBox 1&#60;br /&#62;
&#38;lt;input type=&#38;quot;checkbox&#38;quot; name=&#38;quot;checkbox&#38;quot; value=&#38;quot;checkbox&#38;quot; onClick=&#38;quot;contar();&#38;quot;&#38;gt;&#60;br /&#62;
CheckBox 2&#60;br /&#62;
&#38;lt;input type=&#38;quot;checkbox&#38;quot; name=&#38;quot;checkbox&#38;quot; value=&#38;quot;checkbox&#38;quot; onClick=&#38;quot;contar();&#38;quot;&#38;gt;&#60;br /&#62;
CheckBox 3&#60;br /&#62;
&#38;lt;input type=&#38;quot;checkbox&#38;quot; name=&#38;quot;checkbox&#38;quot; value=&#38;quot;checkbox&#38;quot; onClick=&#38;quot;contar();&#38;quot;&#38;gt;&#60;br /&#62;
CheckBox 4&#60;br /&#62;
&#38;lt;input type=&#38;quot;checkbox&#38;quot; name=&#38;quot;checkbox&#38;quot; value=&#38;quot;checkbox&#38;quot; onClick=&#38;quot;contar();&#38;quot;&#38;gt;&#60;br /&#62;
CheckBox 5&#60;br /&#62;
&#38;lt;input type=&#38;quot;checkbox&#38;quot; name=&#38;quot;checkbox&#38;quot; value=&#38;quot;checkbox&#38;quot; onClick=&#38;quot;contar();&#38;quot;&#38;gt;&#60;br /&#62;
CheckBox 6&#60;br /&#62;
&#38;lt;input type=&#38;quot;checkbox&#38;quot; name=&#38;quot;checkbox&#38;quot; value=&#38;quot;checkbox&#38;quot; onClick=&#38;quot;contar();&#38;quot;&#38;gt;&#60;br /&#62;
CheckBox 7&#60;br /&#62;
&#38;lt;input type=&#38;quot;checkbox&#38;quot; name=&#38;quot;checkbox&#38;quot; value=&#38;quot;checkbox&#38;quot; onClick=&#38;quot;contar();&#38;quot;&#38;gt;&#60;br /&#62;
CheckBox 8&#60;br /&#62;
&#38;lt;input type=&#38;quot;checkbox&#38;quot; name=&#38;quot;checkbox&#38;quot; value=&#38;quot;checkbox&#38;quot; onClick=&#38;quot;contar();&#38;quot;&#38;gt;&#60;br /&#62;
CheckBox 9&#60;br /&#62;
&#38;lt;input type=&#38;quot;checkbox&#38;quot; name=&#38;quot;checkbox&#38;quot; value=&#38;quot;checkbox&#38;quot; onClick=&#38;quot;contar();&#38;quot;&#38;gt;&#60;br /&#62;
CheckBox 10&#60;br /&#62;
&#38;lt;input type=&#38;quot;text&#38;quot; value=&#38;quot;&#38;quot; id=&#38;quot;cajaTexto&#38;quot;&#38;gt;&#60;/p&#62;
&#60;p&#62;&#38;lt;/form&#38;gt;&#60;/p&#62;
&#60;p&#62;&#38;lt;/body&#38;gt;&#60;br /&#62;
&#38;lt;/html&#38;gt;&#60;/p&#62;
&#60;p&#62;Espero que te sirva de ayuda,&#60;/p&#62;
&#60;p&#62;Un saludo
&#60;/p&#62;</description>
		</item>
		<item>
			<title>droche on "Contar Checkbox"</title>
			<link>http://www.dudasprogramacion.com/topic/contar-checkbox#post-333</link>
			<pubDate>Mon, 08 Mar 2010 14:05:47 +0000</pubDate>
			<dc:creator>droche</dc:creator>
			<guid isPermaLink="false">333@http://www.dudasprogramacion.com/</guid>
			<description>&#60;p&#62;Hola a todos. A ver si me podeis ayudar con lo siguiente: Tengo este codigo que he cogido de la seccion de Javascript y que es un contador de checkbox:&#60;br /&#62;
&#38;lt;html&#38;gt;&#60;br /&#62;
&#38;lt;head&#38;gt;&#60;br /&#62;
&#38;lt;title&#38;gt;Cuenta CheckBox&#38;lt;/title&#38;gt;&#60;/p&#62;
&#60;p&#62;&#38;lt;script language=&#38;quot;javascript&#38;quot;&#38;gt;&#60;/p&#62;
&#60;p&#62;function contar() {&#60;/p&#62;
&#60;p&#62;var checkboxes = form1.checkbox; //Array que contiene los checkbox&#60;br /&#62;
var cont = 0; //Variable que lleva la cuenta de los checkbox pulsados&#60;/p&#62;
&#60;p&#62;for (var x=0; x &#38;lt; checkboxes.length; x++) {&#60;br /&#62;
if (checkboxes[x].checked) {&#60;br /&#62;
cont = cont + 1;&#60;br /&#62;
}&#60;br /&#62;
}&#60;/p&#62;
&#60;p&#62;alert (&#38;quot;El número de checkbox pulsados es &#38;quot; + cont);&#60;/p&#62;
&#60;p&#62;}&#60;br /&#62;
&#38;lt;/script&#38;gt;&#60;/p&#62;
&#60;p&#62;&#38;lt;/head&#38;gt;&#60;/p&#62;
&#60;p&#62;&#38;lt;body bgcolor=&#38;quot;#FFFFFF&#38;quot; text=&#38;quot;#000000&#38;quot;&#38;gt;&#60;/p&#62;
&#60;p&#62;&#38;lt;form name=&#38;quot;form1&#38;quot; method=&#38;quot;post&#38;quot; action=&#38;quot;&#38;quot;&#38;gt;&#60;br /&#62;
&#38;lt;input type=&#38;quot;checkbox&#38;quot; name=&#38;quot;checkbox&#38;quot; value=&#38;quot;checkbox&#38;quot;&#38;gt;&#60;br /&#62;
CheckBox 1&#60;br /&#62;
&#38;lt;input type=&#38;quot;checkbox&#38;quot; name=&#38;quot;checkbox&#38;quot; value=&#38;quot;checkbox&#38;quot;&#38;gt;&#60;br /&#62;
CheckBox 2&#60;br /&#62;
&#38;lt;input type=&#38;quot;checkbox&#38;quot; name=&#38;quot;checkbox&#38;quot; value=&#38;quot;checkbox&#38;quot;&#38;gt;&#60;br /&#62;
CheckBox 3&#60;br /&#62;
&#38;lt;input type=&#38;quot;checkbox&#38;quot; name=&#38;quot;checkbox&#38;quot; value=&#38;quot;checkbox&#38;quot;&#38;gt;&#60;br /&#62;
CheckBox 4&#60;br /&#62;
&#38;lt;input type=&#38;quot;checkbox&#38;quot; name=&#38;quot;checkbox&#38;quot; value=&#38;quot;checkbox&#38;quot;&#38;gt;&#60;br /&#62;
CheckBox 5&#60;br /&#62;
&#38;lt;input type=&#38;quot;checkbox&#38;quot; name=&#38;quot;checkbox&#38;quot; value=&#38;quot;checkbox&#38;quot;&#38;gt;&#60;br /&#62;
CheckBox 6&#60;br /&#62;
&#38;lt;input type=&#38;quot;checkbox&#38;quot; name=&#38;quot;checkbox&#38;quot; value=&#38;quot;checkbox&#38;quot;&#38;gt;&#60;br /&#62;
CheckBox 7&#60;br /&#62;
&#38;lt;input type=&#38;quot;checkbox&#38;quot; name=&#38;quot;checkbox&#38;quot; value=&#38;quot;checkbox&#38;quot;&#38;gt;&#60;br /&#62;
CheckBox 8&#60;br /&#62;
&#38;lt;input type=&#38;quot;checkbox&#38;quot; name=&#38;quot;checkbox&#38;quot; value=&#38;quot;checkbox&#38;quot;&#38;gt;&#60;br /&#62;
CheckBox 9&#60;br /&#62;
&#38;lt;input type=&#38;quot;checkbox&#38;quot; name=&#38;quot;checkbox&#38;quot; value=&#38;quot;checkbox&#38;quot;&#38;gt;&#60;br /&#62;
CheckBox 10&#60;br /&#62;
&#38;lt;input type=&#38;quot;button&#38;quot; name=&#38;quot;Submit&#38;quot; value=&#38;quot;Contar&#38;quot; onClick=&#38;quot;contar();&#38;quot;&#38;gt;&#60;br /&#62;
&#60;br /&#62;
&#38;lt;/form&#38;gt;&#60;/p&#62;
&#60;p&#62;&#38;lt;/body&#38;gt;&#60;br /&#62;
&#38;lt;/html&#38;gt;&#60;br /&#62;
Mi problema es que quiero que segun los vayas seleccionando, en un cuadro de texto te vayan saliendo los que tienes seleccionados, es decir, que sea on-line, y no que te lo diga cuando le das al boton. Muchas gracias por vuestra ayuda.
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
