473,396 Members | 1,773 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,396 software developers and data experts.

Check the value of all combo boxes on a page

I have a page with many, dynamically generated combo boxes and I want
to check all of them, before I add a unique value to specific combo.
What would be the best way to work through the document and without
needing to know the name of each combo box, check its value?

Thanks,

Stephen
Jul 23 '05 #1
2 3783
Stephen Miller wrote:
I have a page with many, dynamically generated combo boxes and I want
to check all of them, before I add a unique value to specific combo.
What would be the best way to work through the document and without
needing to know the name of each combo box, check its value?


There is no such thing like combo boxes in HTML. You probably mean
check boxes:

if (document.getElementsByTagName)
{
var o = document.getElementsByTagName('input');
if (o)
{
for (var i = o.length; i--; 0)
{
if (o.type = "checkbox")
{
o.checked = true;
}
}
}
}

What do users without support for client-side JS?
PointedEars
--
"Birth gives rise to old age and death."
-- Siddhartha Gautama, the Buddha
Jul 23 '05 #2
In article <cd**************************@posting.google.com >,
js******@hotmail.com enlightened us with...
I have a page with many, dynamically generated combo boxes
You mean select elements?
Combo boxes are VB and allow both a selection and text input.
and I want
to check all of them, before I add a unique value to specific combo.
What would be the best way to work through the document and without
needing to know the name of each combo box, check its value?


Please explain what you mean by "check its value".
Select elements have options. They also have a selectedIndex property to tell
which option has been chosen. The options have values.
Do you want to check what options (option values) are in each select, which
option has been chosen for a select...?

To iterate through a form, named "form1":

var L = document.forms["form1"].elements.length;
for (var i=0; i<L; i++)
{
/* 'e' will be a form element; do whatever with it */
var e = document.forms["form1"].elements[i];
}

'e' will have a type, name, and all other attributes associated with a form
element.
Example:
alert(e.name);
alert(e.type);

I'm assuming the elements are in a form. The above is more cross-browser than
using getElementsByTagName, but I think it's also slower. Using
getElementsByTagName, however, will allow you to get all the select elements
across ALL forms in a page if you have multiple forms, not just one. There's
pros and cons to each choice.
And don't forget - not everyone has javascript enabled or even available.

HTH
--
--
~kaeli~
A man needs a mistress... just to break the monogamy.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 23 '05 #3

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

Similar topics

0
by: Vic Spainhower | last post by:
Hello, I am new to php and mySQL so this is probably something very basic that I'm missing. Basically, on the page I have 2 combo boxes but 1 of them is not getting the value passed when the...
5
by: jdph40 | last post by:
Is there any way to do this on a form in Access 97? If the value of a combo box is .5, I want two check boxes to be visible (labels are a.m and p.m.). If the value of the combo box is 1, I want...
2
by: Chris Windsor | last post by:
I hope the following describe what I'm trying to do: I have created a tool to be used by product analysts when studying different cell phone designs. Part of the tool is a set of 11 forms on a...
4
by: Steve Chatham | last post by:
I have a page where I have some combo boxes on it. A click on each one spawns another box, and another until each area has been selected, or until they choose to pull all items into a datagrid...
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...
4
by: Torilyn73 | last post by:
I have a combo box set up off a query. I want the default value to be the column heading so I don't have to put a label over it. So far I haven't been able to figure this out. Can anyone tell me if...
6
by: Dave | last post by:
I want to put the information that the user selects in my combo boxes into a subform that lies on the same form as the combo boxes. Thanks for your help already, Dave
1
by: mfaisalwarraich | last post by:
Hi Experts Around the World. I made a table called mainTable, two fields of this table one is SNO and other is Relation are text data types. SNO and Relation can be any string values. Relation stores...
2
kmartinenko
by: kmartinenko | last post by:
Hi everyone, I have several combo boxes on my form, and while I have designated a column head, I cannot figure out how to default to the column head value. What I really want is for all of my...
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: 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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
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,...

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.