Hi.
I've got such html source:
<form name=my_form>
<input type=checkbox class="a"><inpu t type=checkbox class="b"><br>
<input type=checkbox class="a"><inpu t type=checkbox class="b"><br>
<input type=checkbox class="a"><inpu t type=checkbox class="b"><br>
<input type=checkbox class="a"><inpu t type=checkbox class="b"><br>
<input type=checkbox class="a"><inpu t 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.for mularz.elements
for(i=0;i<cb.le ngth;i++)
if(cb[i].type=='checkbo x'){
t[t.length]=cb[i]
cb[i].onclick=functi on(){
for(l=i=0;i<t.l ength;i++)
if(t[i].checked){l++;i f(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
I've got such html source:
<form name=my_form>
<input type=checkbox class="a"><inpu t type=checkbox class="b"><br>
<input type=checkbox class="a"><inpu t type=checkbox class="b"><br>
<input type=checkbox class="a"><inpu t type=checkbox class="b"><br>
<input type=checkbox class="a"><inpu t type=checkbox class="b"><br>
<input type=checkbox class="a"><inpu t 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.for mularz.elements
for(i=0;i<cb.le ngth;i++)
if(cb[i].type=='checkbo x'){
t[t.length]=cb[i]
cb[i].onclick=functi on(){
for(l=i=0;i<t.l ength;i++)
if(t[i].checked){l++;i f(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
Comment