please help with checkboxes

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • abs

    please help with checkboxes

    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


  • abs

    #2
    Re: please help with checkboxes

    Janwillem Borleffs wrote:[color=blue]
    > Normally you would name the checkboxes because you cannot use their
    > values otherwise. When you do, you can use the following: [...][/color]

    Big thanks !

    Regards,
    ABS


    Comment

    Working...