By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,287 Members | 1,665 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,287 IT Pros & Developers. It's quick & easy.

please help with checkboxes

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
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.