Tema: checkbox
Ver Mensaje Individual
  #2 (permalink)  
Antiguo 30/01/2002, 13:36
bet
 
Fecha de Ingreso: febrero-2001
Mensajes: 292
Antigüedad: 23 años, 9 meses
Puntos: 0
Re: checkbox

Algo así te puede servir?

<pre>
&lt;html&gt;
&lt;head&gt;
&lt;title&gt; Uno solo &lt;/title&gt;

&lt;script language=&quot;JavaScript&quot;&gt;
&lt;!--
function checkForm(frm){
var x = 0;
for (i=0;i&lt;document.forms[ 0 ].length;i++){
if ((document.forms[ 0 ].elements[ i ].type) == &quot;checkbox&quot;){
x = x + (document.forms[ 0 ].elements[ i ].checked)?1:0;
}
}
if (x &lt; 1){
alert(&quot;No marcó ninguno&quot;);
return false;
}
else
document.forms[ 0 ].submit();
}


//--&gt;
&lt;/script&gt;
&lt;/head&gt;

&lt;body bgcolor=&quot;#FFFFFF&quot;&gt;
&lt;form method=&quot;post&quot; action=&quot;&quot; onsubmit=&quot;return checkForm(this);&quot;&gt;
Marcar:
&lt;input type=&quot;checkbox&quot;&gt; &lt;br&gt;
&lt;input type=&quot;checkbox&quot;&gt; &lt;br&gt;
&lt;input type=&quot;checkbox&quot;&gt; &lt;br&gt;
&lt;input type=&quot;checkbox&quot;&gt; &lt;br&gt;
&lt;input type=&quot;checkbox&quot;&gt; &lt;br&gt;
&lt;input type=&quot;checkbox&quot;&gt; &lt;br&gt;
&lt;input type=&quot;checkbox&quot;&gt; &lt;br&gt;
&lt;input type=&quot;checkbox&quot;&gt; &lt;br&gt;
&lt;input type=&quot;checkbox&quot;&gt; &lt;br&gt;
&lt;input type=&quot;checkbox&quot;&gt; &lt;br&gt;
&lt;input type=&quot;checkbox&quot;&gt; &lt;br&gt;
&lt;input type=&quot;checkbox&quot;&gt; &lt;br&gt;
&lt;input type=&quot;checkbox&quot;&gt; &lt;br&gt;
&lt;input type=&quot;checkbox&quot;&gt; &lt;br&gt;
&lt;input type=&quot;checkbox&quot;&gt; &lt;br&gt;
&lt;input type=&quot;submit&quot;&gt;
&lt;/form&gt;

&lt;/body&gt;
&lt;/html&gt;
</pre>

OJO!! donde dice [ 0 ] y [ i ], sacale los espacios en blanco. Acá los puse porque sino no me toma bien el código :(

<hr noshade size=1 color="#000000"><img src="http://www.gograph.com/Images-8712/ClipArt/cat03.gif" height="50" border=0 align="absmiddle"> <font size="2" face="verdana" color="#000000">bet[/CODE]