473,508 Members | 2,216 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

selecting all options in a dropdown

I have a drop down with alot of options say about 6000 cities and
districts. I need to select all options if user selects "All checkbox".
I use "on change" and a for loop to do this, but it takes a lot of time
to select all these options. Is there any faster way to select all
these options?

function selectAll()
{
var element = document.getElementById("location");
var length = document.getElementById("location").length;

for(var i=0; i<length; i++)
{
element.options[i].selected=true;
}
}

Jul 23 '05 #1
3 1943
Lee
debugger said:

I have a drop down with alot of options say about 6000 cities and
districts. I need to select all options if user selects "All checkbox".
I use "on change" and a for loop to do this, but it takes a lot of time
to select all these options. Is there any faster way to select all
these options?


1. 6000 entries is far too many for a drop down.
2. If you need to select all of 6000 entries, just have
a checkbox marked "all". No need to actually select them.

Jul 23 '05 #2
thanks for your reply. Well, i need to add few things to my question.
the total is about 6000, but this drop depends on the input from the
other drop down. So, at one time, only about five hundred are in this
drop down. Now, is there any other way of optimizing the above code?

Jul 23 '05 #3
debugger wrote:
thanks for your reply. Well, i need to add few things to my question.
the total is about 6000, but this drop depends on the input from the
other drop down. So, at one time, only about five hundred are in this
drop down. Now, is there any other way of optimizing the above code?

You need to think about your architecture: a user isn't going to click
on even a fraction of 500 list entries, particularly in a dropdown,
still less in a multi-select dropdown (which are almost impossible to use).

If you have 6000 locations, then on page 1, offer "all" or
"Europe/Africa/USA, etc.". On page 2, assuming Europe, offer "all" or
"UK, France, Germany, etc.". On page 3, assuming France, offer "all" or
"Paris, Lyons, Strasbourg, etc." This isn't JavaScript, but sometimes
the best code is no code at all :-)

Jul 23 '05 #4

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

Similar topics

10
2274
by: JL | last post by:
Does anyone have any ideas on this please? I don't know how to evaluate the no-blank selections against each other from a form as follows: . I have a form with 6 dropdown fields, each...
1
3597
by: jzhang29 | last post by:
I have a JSP page and it contains a dropdown list called Office. What I try to do is: When I select different office from this list, the information of office (address, phone,etc) will be...
4
1975
by: Doslil | last post by:
I have a form which has a subform.In the main form I have only one field (this is a drop down list and has a query attached to it) which selects empno,Name from the EmployeeInformation table. ...
2
2043
by: ahoodless | last post by:
hi i have a problem that I have tried desperately to tackle but cannot seem to complete. basically i am trying to create a form with three dropdown lists, the tricky part is i want the 3rd drop...
3
3014
by: sewerized | last post by:
Hello all, I'm having a problem with a user preferences form I'm creating. I want to use dynamic dropdown SELECT boxes for this so my page doesn't get cluttered with 100000 links. Since I...
2
1122
by: peterdorling | last post by:
i have built a table but need one of the options on one of my drop down menu's to require a date to be inputed if you choose it. e.g the options on the dropdown are To Book, Booked, ReBook, Cancel. i...
4
3415
by: Panna | last post by:
Hey there I am using phpMyAdmin and MySQL to develop a dbase application. I have a dropdown menu on one of the pages which gets populated automatically with data from a table in the database....
3
5855
by: dufnobles via AccessMonster.com | last post by:
I have a form that displays a dropdown box. The options in the drop down vary according to a value queried from a database boolean (Yes/No) field. I would like to do the following: If the...
2
11211
by: ghjk | last post by:
I have a dropdown box and what i want to do is refresh the page when i select one of the options, but i need to keep that variable that i chose as it effects my sql statements.
0
7227
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
7391
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
7501
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
5633
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,...
1
5056
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...
0
4713
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...
0
1564
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 ...
1
768
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
424
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...

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.