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

Quickest way to access very long drop down lists

Hello
I am making a webpage with two dropdown menus.
First I have a dropdown menu with a list of 235 countries. When one
country is selected from this list the contents of the next dropdown
menu is decided from a coresponding file containing a huge amount of
cities. The biggest of these files being 6 MB.

Getting different advices I have now to different sets of code doing
this thing. Does anyone know if any of these two sets of code is
suitable for what I want?

Here comes an example of the first set of code - Example 1:
First the main file:
<HTML>
<Title>Choose countries and cities from dropdown</Title>
<SCRIPT>
var va_optionslist=['Canada', 'USA', 'Norway', 'Mexico'];
function Publish_CountryList()
{
var vo_options;
for (var i=0; i<va_optionslist.length; i++)
{
vo_options = new Option(va_optionslist[i], va_optionslist[i]);
document.myForm.SEL_Countries.options[i]=vo_options;
}
document.myForm.SEL_Countries.value='USA';
}
function Update_CityList(po_CountryObj)
{
window.frames['ifm1'].location.href = po_CountryObj.value + '.htm';
}
</SCRIPT>
<BODY onload="Publish_CountryList()">
<form name="myForm">
<SELECT id="SEL_Countries" name="SEL_Countries"
onChange="Update_CityList(this)">
<OPTION value=0>Please Select A Country</Option>
</SELECT>
</form>
<iframe name=ifm1 id='ifm1' src="USA.htm">
</BODY>
</HTML>

and then coresponding data file for one country: (USA)
<HTML>
<Title>City data for USA</Title>
<SCRIPT>
var va_optionslist=['New York City', 'District Of Columbia', 'San
Fransisco', 'Los Angeles'];
function Update_CityList()
{
document.myForm.SEL_Cities.innerHTML="";
for (var i=0; i<va_optionslist.length; i++)
{
document.myForm.SEL_Cities.options[i]=new Option(va_optionslist[i],
va_optionslist[i]);
}
}
</SCRIPT>
<BODY onload="Update_CityList()">
<form name="myForm">
<SELECT id="SEL_Cities" name="SEL_Cities">
<OPTION value=0>Please Select A City</Option>
</SELECT>
</form>
</BODY>
</HTML>
Here comes an example of the second set of code - Example 2:
First the main file:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Choose countries and cities from dropdown</title>
</head>
<body>
<form name="myForm" action="someServerScript.php" target="ifm">
<select onChange="window.frames['ifm1'].location.href=this.value">
<option value='0'>Please Select A Country</option>
<option value='Canada.htm'>Canada</option>
<option value='USA.htm'>United States</option>
<option value='Norway.htm'>Norway</option>
<option value='Mexico.htm'>Mexico</option>
</select>
</form>
<iframe name='ifm1' src="USA.htm">
</body>
</html>

and then the coresponding data file for one country: USA
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>City data for USA</title>
</head>
<body>
<form name="myForm"
<select id="SEL_Cities">
<option value="0">Please Select A City</option>
<option value="New York City">New York City</option>
<option value="District Of Columbia">District Of Columbia</option>
<option value="San Francisco">San Francisco</option>
<option value="Los Angeles">Los Angeles</option>
</select>
</form>
</body>
</html>

Each city in USA is identified with name, county and state. (Short form
in example) And there is about 100000 places in the list so it is
important to make the USA.htm as small as possible.
When each city is mentioned twice in the code I think maybe this will
take to much space? And resulting in longer time needed to load the
information?:
<option value="District Of Columbia">District Of Columbia</option>

Odin

Sep 27 '05 #1
4 2045
Odin wrote:
Hello
I am making a webpage with two dropdown menus.
First I have a dropdown menu with a list of 235 countries. When one
country is selected from this list the contents of the next dropdown
menu is decided from a coresponding file containing a huge amount of
cities. The biggest of these files being 6 MB.
Do the search on the server, that way:

- You won't dump 6 MB onto the client when they want maybe 5 words

- You have far better searching capability (soundex, indexes, other)

- You have consistent and known performance - you have no idea what the
client machine is or isn't capable of

Getting different advices I have now to different sets of code doing
this thing. Does anyone know if any of these two sets of code is
suitable for what I want?

Here comes an example of the first set of code - Example 1:
First the main file:
<HTML>
<Title>Choose countries and cities from dropdown</Title>
<SCRIPT>
The type attribute is required:

<script type="text/javascript">

[...] <body>
<form name="myForm" action="someServerScript.php" target="ifm">
<select onChange="window.frames['ifm1'].location.href=this.value">
<option value='0'>Please Select A Country</option>
<option value='Canada.htm'>Canada</option>
<option value='USA.htm'>United States</option>
<option value='Norway.htm'>Norway</option>
<option value='Mexico.htm'>Mexico</option>
You can trim down your code by not including the closing </option> tag
(it's optional in HTML 4).

[...] Each city in USA is identified with name, county and state. (Short form
in example) And there is about 100000 places in the list so it is
important to make the USA.htm as small as possible.
When each city is mentioned twice in the code I think maybe this will
take to much space? And resulting in longer time needed to load the
information?:
<option value="District Of Columbia">District Of Columbia</option>


You can further trim bloat by using the text only and don't include a
value attribute:

<option>District Of Columbia

then get the options text attribute rather than the value, something like:

var state = theSelect(theSelect.selectedIndex).text;

[...]

--
Rob
Sep 28 '05 #2
ASM
Odin a écrit :
Hello
I am making a webpage with two dropdown menus.
First I have a dropdown menu with a list of 235 countries.
Ho! no ! poor !
how to find something in this crowdly list ?
When one
country is selected from this list the contents of the next dropdown
menu is decided from a coresponding file containing a huge amount of
cities. The biggest of these files being 6 MB.
Hu ? you mean : 6ko , no ?
Getting different advices I have now to different sets of code doing
this thing.
Haaa !
Does anyone know if any of these two sets of code is
suitable for what I want?

Here comes an example of the first set of code - Example 1:
First the main file:
<HTML>
<Title>Choose countries and cities from dropdown</Title>
<SCRIPT>
var va_optionslist=['Canada', 'USA', 'Norway', 'Mexico'];
var va_optionslist=['Canada', 'USA', 'South-America', 'Africa', 'Asia', ...];
function Publish_CountryList()
{
var vo_options;
for (var i=0; i<va_optionslist.length; i++)
{
vo_options = new Option(va_optionslist[i], va_optionslist[i]);
document.myForm.SEL_Countries.options[i]=vo_options;
}
document.myForm.SEL_Countries.value='USA';
}
function Update_CityList(po_CountryObj)
{
var U = po_CountryObj.options[po_CountryObj.selectedIndex].value
parent.frames['ifm1'].location.href = U+'.htm';
window.frames['ifm1'].location.href = po_CountryObj.value + '.htm';
}
</SCRIPT>
<BODY onload="Publish_CountryList()">
<form name="myForm">
<SELECT id="SEL_Countries" name="SEL_Countries"
onChange="Update_CityList(this)">
<OPTION value=0>Please Select A Country</Option>
</SELECT>
</form>
<iframe name=ifm1 id='ifm1' src="USA.htm">
</BODY>
</HTML>

and then coresponding data file for one country: (USA)
<HTML>
<Title>City data for USA</Title>
<SCRIPT>
var va_optionslist=['New York City', 'District Of Columbia', 'San
Fransisco', 'Los Angeles'];
no alphetical list ?
function Update_CityList()
{
document.myForm.SEL_Cities.innerHTML="";
for (var i=0; i<va_optionslist.length; i++)
{
document.myForm.SEL_Cities.options[i]=new Option(va_optionslist[i],
va_optionslist[i]);
}
}
</SCRIPT>
<BODY onload="Update_CityList()">
<form name="myForm">
<SELECT id="SEL_Cities" name="SEL_Cities">
<OPTION value=0>Please Select A City</Option>
</SELECT>
</form>
</BODY>
</HTML>
Here comes an example of the second set of code - Example 2:
First the main file:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Choose countries and cities from dropdown</title>
</head>
<body>
<form name="myForm" action="someServerScript.php" target="ifm">
<form name="myForm" action="" target="ifm">
<select onChange="window.frames['ifm1'].location.href=this.value">
no ! don't put an onchange
(overall if it doesn't work with any browser)
<option value='0'>Please Select A Country</option>
<option value='Canada.htm'>Canada</option>
<option value='USA.htm'>United States</option>
<option value='Norway.htm'>Norway</option>
<option value='Mexico.htm'>Mexico</option>
</select>
<input type=submit value="GO"
onclick="this.form.action=this.form[0].options[this.form[0].selectedIndex].value;">
</form>
<iframe name='ifm1' src="USA.htm">
</body>
</html>
this second way smells beter because you can have different
names for html files and for countries
(it's beter to have 'usa.htm' than 'united states.htm'
that's to say without a space in file name)
take care to be in habit to name your files all in lower case
to avoid mistakes with caracters forgotten in upper case
and then the coresponding data file for one country: USA
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>City data for USA</title>
</head>
<body>
<form name="myForm"
<select id="SEL_Cities">
<option value="0">Please Select A City</option>
<option value="New York City">New York City</option>
<option value="District Of Columbia">District Of Columbia</option>
<option value="San Francisco">San Francisco</option>
<option value="Los Angeles">Los Angeles</option>
</select>
</form>
</body>
</html>

Each city in USA is identified with name, county and state. (Short form
in example) And there is about 100000 places in the list so it is
important to make the USA.htm as small as possible.
When each city is mentioned twice in the code I think maybe this will
take to much space? And resulting in longer time needed to load the
information?:
<option value="District Of Columbia">District Of Columbia</option>

You could have : data('dc_colbia-District Of Columbia','ny-New York City')

function set_select() {
for(var i=0;i<data.length;i++) {
var O = data[i].split('-');
vo_options = new Option(O[0], O[1]);
document.myForm.SEL_Countries.options[i]=vo_options;
}
}

and
<input type=submit value="GO"
onclick="this.form.action=this.form[0].options[this.form[0].selectedIndex].value+'.htm';">
--
Stephane Moriaux et son [moins] vieux Mac
Sep 28 '05 #3
Thank you for your answers
Following your advices I change the code to:

Main file:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Choose countries and cities from dropdown</title>
</head>
<script type="text/javascript">
function DeleteText(tekst)
{
tekst.value='';
}
function FindCities()
{
window.frames['ifm1'].location.href=document.myForm1.SEL_Countries.valu e+'_'+document.myForm1.StartStedsNavn.value+'.htm'
}
</script>
<body>
<form name="myForm1" action="../someServerScript.php" target="ifm">
<select id="SEL_Countries" name="SEL_Countries" >
<option value='0'>Please Select A Country
<option selected value='USA'>USA
<option value='Norway'>Norway
<option value='Canada'>Canada
<option value='Mexico'>Mexico
</select>
<p>
<input onkeyup="FindCities()" onkeydown="DeleteText(this)"
onclick="DeleteText(this)" type="text" name="StartStedsNavn"
value="Type first letter in Place of Birth" size="29"></p>
<p>&nbsp;</p>
</form>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>Place of Birth</p>
<iframe name='ifm1' src="USA_a.htm" width="222" height="197">
</body>
</html>

and data file "USA_a.htm":
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>City data for USA starting with letter A</title>
</head>
<body>
<form name="myForm"
<p>
<select id="SEL_Cities" size="1">
<option>Please Select A City
<option>Alabama
<option>Alamo
<option>Albert
<option>Alexis
</select>
</p>
</form>
</body>
</html>

Using an alpabetical list and making the data files smaller.
- You have far better searching capability (soundex, indexes, other)

How do I do this?

Odin

Sep 28 '05 #4
Odin wrote:
Thank you for your answers [...]
Using an alpabetical list and making the data files smaller.

- You have far better searching capability (soundex, indexes, other)


How do I do this?


On the server, but that is a question for a group oriented toward your
particular server and database combination.

As for the client UI, try the google suggest page here - just start
typing into the text field and suggestions are made:

<URL:http://www.google.com/webhp?complete=1&hl=en>

More info:

<URL:http://serversideguy.blogspot.com/2004/12/google-suggest-dissected.html>


--
Rob
Sep 28 '05 #5

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

Similar topics

2
by: Phil Longworth | last post by:
Im very new to Access 97 and Im sure I should be able to do this but cant work out how. Im bulding a database for my stamp collection. I have two tables; one with details of all the individual...
4
by: Bob Alston | last post by:
Some more, rather specific Access performance questions. IN a split front-end & back-end Access/Jet ONLY LAN situation, and with all query criteria fields and join fields indexed: 1. Is is...
3
by: Miguel Dias Moura | last post by:
Hello, i have an ASP.NET / VB page where i have a few 4 groups of Drop Down Lists. Each group of Drop Down Lists include 3 Drop Down Lists for date such as: DAY, MONTH, and YEAR. I don't want...
13
by: Leszek Taratuta | last post by:
Hello, I have several drop-down lists on my ASP.NET page. I need to keep data sources of these lists in Session State. What would be the most effective method to serialize this kind of data...
2
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...
7
by: Miguel Dias Moura | last post by:
Hello, i have an ASP.NET / VB page where i have a few 4 groups of Drop Down Lists. Each group of Drop Down Lists include 3 Drop Down Lists for date such as: DAY, MONTH, and YEAR. I don't want...
0
by: kajir | last post by:
Hi, I am new at using ASP.Net 2.0. I have various drop down lists on my master page. They refer to an SQL database. I also have a menu on the master page. I can select the values in the drop...
4
by: Bob | last post by:
Hi all, I'm trying to import data, modify the data then insert it into a new table. The code below works fine for it but it takes a really long time for 15,000 odd records. Is there a way I...
3
by: jcassan | last post by:
Hello folks. I am new to these forums and have something, which has been stumping me for little while. I am using pspell to spellcheck a scrolling textbox (textarea) containing user input. I...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...

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.