objects mistake

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

    objects mistake

    Hello,
    when I was trying with a new source code I have the problem with my
    for-loop.
    So I use 'f.elements' but it is to object to this line:
    (var i=0;i<f.element s.length;i++).
    I want to count all elements(checkb oxes).
    Maybe somebody has another source code?
  • Lee

    #2
    Re: objects mistake

    BjoernJackschin a said:[color=blue]
    >
    >Hello,
    >when I was trying with a new source code I have the problem with my
    >for-loop.
    >So I use 'f.elements' but it is to object to this line:
    > (var i=0;i<f.element s.length;i++).
    >I want to count all elements(checkb oxes).
    >Maybe somebody has another source code?[/color]

    It's impossible to guess what you've done wrong from that
    single line of code.

    <html>
    <body>
    <script type="text/javascript">
    function countCheckboxes (f){
    var count=0;
    for(var i=0;i<f.element s.length;i++){
    if(f.elements[i].type=="checkbo x"){
    count++;
    }
    }
    alert("There are "+count+" checkboxes in this form.");
    }
    </script>
    <form>
    <input type="checkbox" >
    <input type="checkbox" >
    <input type="checkbox" >
    <input type="checkbox" >
    <input type="button" value="count" onclick="countC heckboxes(this. form)">
    </form>
    </body>
    </html>

    Comment

    Working...