473,397 Members | 2,116 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,397 software developers and data experts.

counting numebr of combobox

hi,

How can i count number of combobox in my html page.

thanx
Manoj
Jun 11 '07 #1
8 18873
dmjpro
2,476 2GB
hi,

How can i count number of combobox in my html page.

thanx
Manoj
Try this code.

Expand|Select|Wrap|Line Numbers
  1. alert(document.getElementByTagNames('select').length);
  2. //It ll show the total number of combo boxes.
  3.  
Best of luck.

Kind regards,
Dmjpro.
Jun 11 '07 #2
Try this code.

Expand|Select|Wrap|Line Numbers
  1. alert(document.getElementByTagNames('select').length);
  2. //It ll show the total number of combo boxes.
  3.  
Best of luck.

Kind regards,
Dmjpro.
hi dmjpro,

i tried this solution but it is notworking.

Expand|Select|Wrap|Line Numbers
  1.  
  2. <html>
  3. <head>
  4. <title>Customer Inquiry</title>
  5. <SCRIPT language="JavaScript1.2">
  6.  
  7.  
  8. function CLcount()
  9. {
  10.     alert(document.getElementByTagNames('select').length);
  11.  
  12. }
  13.  
  14. </SCRIPT>
  15. </head>
  16. <body>
  17.  
  18.     <form name="sysaccess" >
  19.  
  20.  
  21.  
  22.         <select name="select1" >
  23.         <option value="CL">CL</option>
  24.         <option value="EL">EL</option>
  25.         </select>
  26.  
  27.  
  28.         <select name="select2">
  29.         <option value="CL">CL</option>
  30.         <option value="EL">EL</option>
  31.         </select>
  32.  
  33.         <select name="select2">
  34.         <option value="CL">CL</option>
  35.         <option value="EL">EL</option>
  36.         </select>
  37.  
  38.             <input type="button" onclick="CLcount()">
  39.  
  40.  
  41.  
  42.  
  43.     </form>
  44.  
  45. </body>
  46. </html>
  47.  
Jun 11 '07 #3
dmjpro
2,476 2GB
hi dmjpro,

i tried this solution but it is notworking.

Expand|Select|Wrap|Line Numbers
  1.  
  2. <html>
  3. <head>
  4. <title>Customer Inquiry</title>
  5. <SCRIPT language="JavaScript1.2">
  6.  
  7.  
  8. function CLcount()
  9. {
  10.     alert(document.getElementByTagNames('select').length);
  11.  
  12. }
  13.  
  14. </SCRIPT>
  15. </head>
  16. <body>
  17.  
  18.     <form name="sysaccess" >
  19.  
  20.  
  21.  
  22.         <select name="select1" >
  23.         <option value="CL">CL</option>
  24.         <option value="EL">EL</option>
  25.         </select>
  26.  
  27.  
  28.         <select name="select2">
  29.         <option value="CL">CL</option>
  30.         <option value="EL">EL</option>
  31.         </select>
  32.  
  33.         <select name="select2">
  34.         <option value="CL">CL</option>
  35.         <option value="EL">EL</option>
  36.         </select>
  37.  
  38.             <input type="button" onclick="CLcount()">
  39.  
  40.  
  41.  
  42.  
  43.     </form>
  44.  
  45. </body>
  46. </html>
  47.  
Did u add space in length?
Check it out and try it again without space.
Best of luck.

Kind regards,
Dmjpro.
Jun 11 '07 #4
Did u add space in length?
Check it out and try it again without space.
Best of luck.

Kind regards,
Dmjpro.
hi,

No i didn't after posting it is showing this

manoj
Jun 11 '07 #5
hi,

Its working fine.

thanx
Manoj
Jun 11 '07 #6
hi,

I want to find out how many select option has value Cl select.Can we do this?


thanx
Manoj
Jun 11 '07 #7
acoder
16,027 Expert Mod 8TB
I want to find out how many select option has value Cl select.Can we do this?
Loop through the select elements on the page (which you already have) and check the values. Just .value is usually enough.
Jun 11 '07 #8
iam_clint
1,208 Expert 1GB
wait wait wait...

look at what you guys put... get Element By Tag Names
Expand|Select|Wrap|Line Numbers
  1. alert(document.getElementByTagNames('select').length);
  2.  
where it should be... get Elements By Tag Name
Expand|Select|Wrap|Line Numbers
  1. alert(document.getElementsByTagName('select').length);
  2.  
Expand|Select|Wrap|Line Numbers
  1. function CLcheck() {
  2. var total = 0;
  3. var sels = document.getElementsByTagName('select');
  4. for (i=0; i<sels.length; i++) {
  5. var opts = sels[i].options;
  6. for (c=0; c<opts.length; c++) {
  7.  if (opts[c].value == "CL") { total += 1; }
  8. }
  9. }
  10. alert(total + " Combo boxes had the value CL in its options");
  11. }
  12.  
Jun 11 '07 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Nicolae Fieraru | last post by:
Hi All, I am trying to change the rowsource of a combobox when I click on it. I played with many events, associated with the form and the combobox, but still haven't figured out what is the way...
8
by: Zlatko Matić | last post by:
There is a form (single form) and a combobox. I want that current record of the form is adjusted according to selected value in the combobox. Cuurrent record should be the same as the value in the...
1
by: anonymous | last post by:
I've been trying to put a them, please help me out. Here's the major parts of my code: public Form1() { DataSet myDataSet = new DataSet("myDataSet"); DataTable testTable = new...
3
by: TT (Tom Tempelaere) | last post by:
Hay there, I'm writing my own DataGridComboBoxColumn because .NET 1.1 does not have one (I hope .NET 2.0 supplies one). I based it on this article:...
2
by: Steve Wilkinson | last post by:
Is there any method I can use to determine the number of subscribers to a controls events. In particular I'm looking at the ComboBox.SelectedIndexChanged event, I have a scenario where I need to...
2
by: SKarnis | last post by:
We are trying to rebuild a current Access 2002 (XP) mdb program to VB.NET with a SQL database - we are having problems with a suitable combobox. There are many threads discussing multiple column...
7
by: Simon Verona | last post by:
I posted this in dotnet.languages.vb.controls but thought I'd post here as well.. I have a combobox that is bound to a dataview generated from a dataset. The dataset has a single table...
6
by: dbuchanan | last post by:
VS2005 I've been reading all the help I can on the topic (MSDN, other) but I can't make sense of this. Desired behavior; The user is to choose from the displayed list of the databound combobox...
4
by: aaronfude | last post by:
Hi, Please consider the following class (it's not really my class, but it's a good example for my question): class Vector { int myN; double *myX; Vector(int n) : myN(n), myX(new double) { }...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.