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

objects mistake

P: n/a
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.elements.length;i++).
I want to count all elements(checkboxes).
Maybe somebody has another source code?
Jul 20 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Lee
BjoernJackschina said:

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.elements.length;i++).
I want to count all elements(checkboxes).
Maybe somebody has another source code?


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.elements.length;i++){
if(f.elements[i].type=="checkbox"){
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="countCheckboxes(this.form)">
</form>
</body>
</html>

Jul 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.