473,394 Members | 1,761 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

how to count number of check boxes in a check box list.

hi,

i have a list of checkboxes, the number of checkboxes is dynamic. All
the checkboxes have same name.
i am trying to get the length of selected checkboxes.
<input type=checkbox name=name1 value=1>
<input type=checkbox name=name1 value=2>
........ get dynamically.

when i try to get the length in javascript like
document.form.name1.length,
it works fine if number of checkboxes selected are more than 1, but not
for 1.

any idea.
thanks.

Mar 29 '06 #1
1 4129
babu17 wrote:
hi,

i have a list of checkboxes, the number of checkboxes is dynamic. All
the checkboxes have same name.
i am trying to get the length of selected checkboxes.
<input type=checkbox name=name1 value=1>
<input type=checkbox name=name1 value=2>
....... get dynamically.

when i try to get the length in javascript like
document.form.name1.length,
it works fine if number of checkboxes selected are more than 1, but not
for 1.

any idea.


document.getElementsByName('name1').length;

getElementsByName() always returns an HTMLCollection, even if there are no
elements with the specified name (i.e. the length is zero).
--
Rob
Mar 30 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

22
by: Ling Lee | last post by:
Hi all. I'm trying to write a program that: 1) Ask me what file I want to count number of lines in, and then counts the lines and writes the answear out. 2) I made the first part like this: ...
10
by: Henk Ernst Blok | last post by:
Hi Posgres users/developers, Can anyone explain why PosgreSQL (version 7.4.5 on Linux) does a full table scan to compute a count(*) on a base table after a vacuum analyze has been done with no...
7
by: DP | last post by:
hi, how would u do a count for somthing that is checked, in a check box?? this is wat i've got so far, but its coming out with an error; =DCount("Available","tblFilm","='Checked'") i;ve...
5
by: Shreekant Patel | last post by:
Hello, I am new to the advanced level of access, and I have quite a few changes to make to an existing database. The current database's main form needs to have additional check boxes added to...
2
by: GoCoogs | last post by:
I'm trying to count how many items are in a dynamic collection. This is the code I have so far. *** Begin Code *** Public Class Rule Private _rulevars As RuleVarsCollection Private _rulename...
22
by: MP | last post by:
vb6,ado,mdb,win2k i pass the sql string to the .Execute method on the open connection to Table_Name(const) db table fwiw (the connection opened via class wrapper:) msConnString = "Data Source="...
5
by: Andrew Meador | last post by:
I have a form (Change Card List by Status) with a check box (cboNOT) and a list box (lstStatus). There is an Open Report button that opens a report (Report - Change Card List) which uses a query...
9
by: smarttechie | last post by:
Hii all please help its urgent i have developed an application in xsl. what i want to do is i m searching the xml file based on a search.and based on that search im creating one tree like...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.