469,281 Members | 2,486 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,281 developers. It's quick & easy.

please help with checkboxes

abs
Hi.
I've got such html source:
<form name=my_form>
<input type=checkbox class="a"><input type=checkbox class="b"><br>
<input type=checkbox class="a"><input type=checkbox class="b"><br>
<input type=checkbox class="a"><input type=checkbox class="b"><br>
<input type=checkbox class="a"><input type=checkbox class="b"><br>
<input type=checkbox class="a"><input type=checkbox class="b"><br>
</form>

How to allow user to mark only two checkboxes of class "a" ? Class "b" can
be marked as user want - no matter how much.

There's a function like that:

<script type="text/javascript">
function init(){
var i,l,t=[],ile=2
cb=document.formularz.elements
for(i=0;i<cb.length;i++)
if(cb[i].type=='checkbox'){
t[t.length]=cb[i]
cb[i].onclick=function(){
for(l=i=0;i<t.length;i++)
if(t[i].checked){l++;if(l>ile)return!1}
}
}
}
</script>

but I can't force it to work with checkboxes of class "a" only. Could you
help me ?

Thanks in advance,
Regards,
ABS
Jul 20 '05 #1
1 1724
abs
Janwillem Borleffs wrote:
Normally you would name the checkboxes because you cannot use their
values otherwise. When you do, you can use the following: [...]


Big thanks !

Regards,
ABS
Jul 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by @(none) | last post: by
1 post views Thread by rdlauer | last post: by
7 posts views Thread by Stephen | last post: by
3 posts views Thread by Amy Snyder | last post: by
blazedaces
6 posts views Thread by blazedaces | last post: by
1 post views Thread by Carl Johansson | last post: by
1 post views Thread by CARIGAR | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.