473,654 Members | 3,035 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Loop Thru Drop Down boxes....

I have a page with a bunch of drop down boxes. They are named:

MonEquipAMWk1
MonEquipPMWk1

thru

FriEquipAMWk1
FriEquipPMWk1

(this sequence continues until Wk11)

How do I loop thru these boxes, check their value, & assign an
alternate value if the selection of a box is selection #1?

Many thanx!

jp
Nov 2 '06 #1
2 5061
ck****@REfuse.n et wrote:
I have a page with a bunch of drop down boxes. They are named:

MonEquipAMWk1
MonEquipPMWk1

thru

FriEquipAMWk1
FriEquipPMWk1

(this sequence continues until Wk11)

How do I loop thru these boxes, check their value, & assign an
alternate value if the selection of a box is selection #1?
To loop through the elements, pass a reference to the form to:

function checkSelects(fo rm){
var c1 = ['Wk1','Wk2','Wk 3','Wk4','Wk5', 'Wk6',
'Wk7','Wk8','Wk 9','Wk10','Wk11 '];
var c2 = ['Mon','Tue','We d','Thu','Fri'];
var c3 = ['AM','PM'];
var sel;
for (var i=0, len1=c1.length; i<len1; i++){
for (var j=0, len2=c2.length; j<len2; j++){
for (var k=0, len3=c3.length; k<len3; k++){
sel = form.elements[ c2[j] + 'Equip' + c3[k] + c1[i] ];

/* Check the selected option's value or text (or both)
and set the selectedIndex property to whatever
*/

}
}
}
}

A simpler method is to enclose the selects in a div, then use a
reference to the div and getElementsByTa gName to get the selects and
loop through them:

function checkSelects(di vID){
var div = document.getEle mentById(divID) ;
var sel, sels = div.getElements ByTagName('sele ct');
for (var i=0, len=sels.length ; i<len; i++){
sel = sels[i];
/* do stuff with sel as above */
}
}

Feature detection omitted for brevity, don't forget to include it.
--
Rob

Nov 2 '06 #2
ASM
ck****@REfuse.n et a écrit :
I have a page with a bunch of drop down boxes.
What is a drop down box ?
They are named:

MonEquipAMWk1
MonEquipPMWk1

thru

FriEquipAMWk1
FriEquipPMWk1

(this sequence continues until Wk11)

How do I loop thru these boxes, check their value, & assign an
alternate value if the selection of a box is selection #1?
#1 or first choice ?
Many thanx!
Sorry but without calling things by their names ...


If you are speaking of elements 'select' of a form and of their selected
'options', (all selects as drop down lists) :

Javascript :

function getSelected(myF orm) {
var f = (typeof (myForm) == 'string')?
document.forms[myForm] || document.getEle mentById(myForm ) :
myForm;
var t = '';
for(var i=0; i<f.length; i++) {
if(f[i].tagName.toLowe rCase()=='selec t') {
t += f[i].name+' = ';
var k = f[i].selectedIndex;
if(k==0) t += 'default';
else t += f[i][k].value;
t += '\n';
}
}
return t;
}

Html :

<a href="#" onclick="alert( getSelected('fo rm_1')); return false;">
form 'form_1' choices</a>
Nov 3 '06 #3

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

Similar topics

6
2458
by: PT | last post by:
I got a form with many text boxes, checkboxes and 3 drop downs. From that 3, 2 are dependant. I can choose one drop down, and the next drop down should display the dependant values of the first drop down chosed. And I have a submite button to submit all these values to DB. First problem: I cant keep the value of the selected text in the first drop down. It always goes back to the first value. (but the asp site extension changes...
0
2496
by: Leigh | last post by:
I am building a data entry application using Java servlets. I had hoped to use drop down boxes to provide the user with data entry selections pulled from a database, but am now questioning, given the latency with which the data loads to the browser, whether drop down boxes are viable for providing a large number of select options. I've put nearly-identical examples of the problem on two different web/database hosts for review (I wanted...
4
6296
by: Dan | last post by:
Can anyone offer suggestions on how to do this or if it is possible? I have a form that uses a drop down box and 2 text fields. What I am trying to do is have the value of each text box set by the choice from the drop down box. Something like: <form name="populatefrm" id="contactfrm" method="post"
5
2085
by: MasterChief | last post by:
I have 3 drop down boxes on the same page. Each one is being populated by a database. One is called Location, One is called Device and the other one is called Job Title. When the user selects something from one of the drop down boxes I would like it so it automatically calls the phonelist.asp and passes the variable. What is the best way to do it so I have 3 seperate drop-down boxes that just send their variables. Should I do one form that...
2
12611
by: Yoshitha | last post by:
hi I have 2 drop down lists in my application.1st list ontains itmes like java,jsp,swings,vb.net etc.2nd list contains percentage i.e it conatains the items like 50,60,70,80,90,100. i will select any skill in 1st drop down list then i'll select % of this skill in the 2nd list box , based on the percentage i've selected in the 2nd list box it has to display 2 sets of drop down list boxes at run time one for selecting skill and
5
4219
by: Vigneshwar Pilli via DotNetMonster.com | last post by:
string connectionString1 = "server=(local); user=sa;password=sa; database=sonic"; System.Data.SqlClient.SqlConnection dbConnection1 = new System.Data.SqlClient.SqlConnection(connectionString1); System.Data.SqlClient.SqlCommand dbCommand1 = new System.Data.SqlClient.SqlCommand();
7
2432
by: callawayglfr | last post by:
I am building a database in access where I have a drop down box that relates to a text box, that part I have working but when someone selects information from the first drop down I need it to limit the second drop down to just the related information. Explaining this is obviously challeging. So I'll try to draw a picture: (drop down 1) Select number --- once selected description is populated in text box (drop down 2) based on first...
4
1943
by: teknoshock | last post by:
I have created a page with multiple drop down boxes, all populated with the same options. My problem is, for 12 dropdown boxes and 40 choices per box, I end up with a massive file. Also, if I want to change or add options to a drop down box, I then have to copy that to the other 11 boxes. Would it be possible to define the options once, and then have all of the drop down boxes get their options from the single list? Here is my...
3
2543
by: amcoldspy | last post by:
Hi, am trying to create dynamic drop down boxes.. there are 3 drop down boxes. The second drop down box elements are to be update based on the selection made in the first drop down box (selecting an element on the first drop down box calls a getData.jsp file which returns the result.) the third drop down box elements are to be update based on the selection made in the second drop down box (selecting an element on the second drop down...
0
8376
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
8815
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8489
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7307
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
6161
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
4149
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2716
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
1
1916
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1596
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.