473,671 Members | 2,155 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

counting numebr of combobox

11 New Member
hi,

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

thanx
Manoj
Jun 11 '07 #1
8 18886
dmjpro
2,476 Top Contributor
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
manojsingh
11 New Member
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 Top Contributor
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
manojsingh
11 New Member
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
manojsingh
11 New Member
hi,

Its working fine.

thanx
Manoj
Jun 11 '07 #6
manojsingh
11 New Member
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 Recognized Expert Moderator MVP
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 Recognized Expert Top Contributor
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
8511
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 of doing it. I have a table with products, tblProducts, some of them are Active while others are Inactive. The form shows all the products purchased by a customer, both Active and Inactive in a ComboBox, cbProducts. My client wants to view all...
8
12090
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 combobox. What is the solution? Thank you in advance.
1
2492
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 DataTable("table"); testTable.Columns.Add("Col1", typeof(Int32)); testTable.Columns.Add("Col2", typeof(String)); testTable.Rows.Add(testTable.NewRow());
3
6824
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: http://msdn.microsoft.com/msdnmag/issues/03/08/DataGrids/default.aspx I have a problem when there are two DataGrid's on one form, and when I switch focus from one grid to the other. To be more precise, when I'm editing a combo box column in one grid, and then click in the combo column of...
2
2654
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 cancel the SelectedIndexChanged event and restore the original SelectedIndex property. To do this I unsubscribe the SelectedIndexChanged event, update the SelectedIndex property and then re-subscribe. I need to do this to prevent the...
2
1786
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 comboboxes in .NET. We are having success with the multiple columns similar to the combobox from Access 2002 (XP). Our biggest problem is speed. In a form in Access 2002, our combobox is able to load data in a table in separate Access database...
7
4561
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 (called "Data") with two columns "Id" and "Description". Id contains a code and description contains the description that is displayed in the combobox.
6
2874
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 and the coresponding 'Id' from the lookup table is to be inserted into the field of the new record. I have two simple tables. "tblPerson" is the data table. The lookup
4
4194
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) { } double &operator()(int i) { return myX; }
0
8476
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8820
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8670
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7433
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6223
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5695
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4406
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2810
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2051
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.