I've a page where users may enter a zip code (text edit) and I want to fill
a combobox with existing cities depending on the zip code entered.
Let give an example.
I've my text edit like:
<input name="ZIP" type="text" id="ZIP" onKeyUp="fillci tycombo();">
<select name="City" id="City"></select>
When entering the zip code, I'd like the fillcitycombo() function to fill
the combobox with the matching cities.
For example I've
IDCity ZIP City
1 1950 Sion
2 1950 Pont-de-la-Morge
3 3960 Sierre
4 3960 Corin
So user's entry 3960 should fill the combo with Sierre, ID 3 and Corin, ID
4, as selecting 3 or 4 will change the city (that share the same ZIP code).
Of course the ZIP and city datas will be in the javascript source, as client
side there is no access to the DB. For info, in the client's DB I store the
IDCity code.
Thanks for help.
Bob 12 3167
Hi,
It's what I'm looking for, but I've to generate the list with 4430 records,
so I can't do it manually.
I've now an Excel file with those datas:
columnA : recordID
columnB : City
columnC : Zip code
How to work with such fields with your idea (sorry I'm not so confortable
with js).
Cheers
Bob
"kaeli" <ti******@NOSPA M.comcast.net> a écrit dans le message de
news:MP******** *************** *@nntp.lucent.c om... In article <41************ *********@news. sunrise.ch>, bedford1 @YouKnowWhatToD oHerehotmail.co m enlightened us with... I've a page where users may enter a zip code (text edit) and I want to
fill a combobox with existing cities depending on the zip code entered.
Does this help?
http://www.ipwebdesign.net/kaelisSpa...icSelects.html
-- -- ~kaeli~ The man who fell into an upholstery machine is fully recovered. http://www.ipwebdesign.net/wildAtHeart http://www.ipwebdesign.net/kaelisSpace
In article <41************ *********@news. sunrise.ch>, bedford1
@YouKnowWhatToD oHerehotmail.co m enlightened us with... Hi,
It's what I'm looking for, but I've to generate the list with 4430 records, so I can't do it manually.
I've now an Excel file with those datas: columnA : recordID columnB : City columnC : Zip code
How to work with such fields with your idea (sorry I'm not so confortable with js).
You don't, more than likely.
The answer is highly dependent on environment.
If this is for an intranet/IE-only env, you can use ActiveX to read the file
and stuff.
If it isn't, you need to save the file as text on the server and use some
method of retrieving the values into the JS. Again, depends on env, but
you'll need a server-side script to either get the values and write into the
page before it's generated or one to do it after, similar to: http://www.ipwebdesign.net/kaelisSpa...alidation.html
Either way, there's a server-side scripting language involved.
Basically, standard internet cross-browser javascript cannot read files on
the server all by itself.
If this is a one-time only thing to generate hard-coded javascript based on
the Excel file on your HD, you could make a quick little Excel macro for
that. But I'm assuming the list changes and the JS is dynamic.
If this is to work only for you on your machine, you can use an HTA to read
the Excel.
See, it just all depends on what you're doing, exactly.
--
--
~kaeli~
You can't have everything. Where would you put it? http://www.ipwebdesign.net/wildAtHeart http://www.ipwebdesign.net/kaelisSpace
> The answer is highly dependent on environment. If this is for an intranet/IE-only env, you can use ActiveX to read the
file and stuff.
If it isn't, you need to save the file as text on the server and use some method of retrieving the values into the JS. Again, depends on env, but you'll need a server-side script to either get the values and write into
the page before it's generated or one to do it after, similar to: http://www.ipwebdesign.net/kaelisSpa...alidation.html Either way, there's a server-side scripting language involved.
Basically, standard internet cross-browser javascript cannot read files on the server all by itself.
If this is a one-time only thing to generate hard-coded javascript based
on the Excel file on your HD, you could make a quick little Excel macro for that. But I'm assuming the list changes and the JS is dynamic.
If this is to work only for you on your machine, you can use an HTA to
read the Excel.
Hi Kaeli,
Thanks for your valuable help
1- the file doesn't change (ZIP codes and cities most likely never changes
;-)....)
2- I know the difference between server side and client side. Now I do open
a pop-up (wich have PHP server side code, that retrieves datas from a MySQL
table) and then using JS I fill the combobox with cities that match the ZIP
code.
problem is that some browser (mainly on MAC) don't let this to be done
correctly. Also anti-popup program don't let either do this. So I'm looking
for creating a JS script, wich will be included in the page sent to the
client (the browser) wich a structure giving the possibility to fill the
combo by selecting a ZIP code in a text field. In my coutry, the same ZIP
code may have many little town, so I've to take care at this problem.
So my problem is, depending on the ZIP code selected, fill the combo with
possible town or cities accordingly, and then, when I submit the form, save
the RecordID (that is an unique code for the town).
The structure of my table is:
columnA : recordID
columnB : City
columnC : Zip code
example:
1 Sion 1950
2 Chateauneuf 1950
3 Sierre 3960
4 Corin 3960
5 Monthey 4520
6 St-Maurice 4290
So, if a user enter 3960 in a text field, the JS script should fill the
combo with Sierre and Corin. By selecting Sierre, I've to submit the
RecordID 3 (that will be saved in the database), if the user selects Corin,
the RecordID would be 4
If you have any idea, please let me know.
Cheers,
Bob
I actually did some very similar. I needed to access a database via
javascript and I was in a hurry. You can put the database into a .js file.
The large amount of records makes it prohibitive to do manually. I wrote a
little c program to format the data something like this.
var numVariables=?? ; so I can use a loop efficiently
var varName1 = new Array('data','i d','whatever'); // named and populated
programatically
or
var varName1 = new Array();
varName1.zipCod e=????.
varName1.cityNa me="cityname";
etc
.....
var varNameN = .....
<script etc>
var ind =
document.yourFo rm["formName"].elements["selectName "].selectedIndex;
var myVar = eval("varName" + ind);
var myZipCode=myVar .zipCode
etc
</script>
This is not something you want to code manually and not a good long term
solution. But it will work!! >) Hope this helps.
Jimbo
"Bob Bedford" <be******@YouKn owWhatToDoHereh otmail.com> wrote in message
news:41******** *************@n ews.sunrise.ch. .. The answer is highly dependent on environment.
If this is for an intranet/IE-only env, you can use ActiveX to read the file and stuff.
If it isn't, you need to save the file as text on the server and use
some method of retrieving the values into the JS. Again, depends on env, but you'll need a server-side script to either get the values and write into the page before it's generated or one to do it after, similar to: http://www.ipwebdesign.net/kaelisSpa...alidation.html Either way, there's a server-side scripting language involved.
Basically, standard internet cross-browser javascript cannot read files
on the server all by itself.
If this is a one-time only thing to generate hard-coded javascript based on the Excel file on your HD, you could make a quick little Excel macro for that. But I'm assuming the list changes and the JS is dynamic.
If this is to work only for you on your machine, you can use an HTA to read the Excel.
Hi Kaeli,
Thanks for your valuable help
1- the file doesn't change (ZIP codes and cities most likely never changes ;-)....) 2- I know the difference between server side and client side. Now I do
open a pop-up (wich have PHP server side code, that retrieves datas from a
MySQL table) and then using JS I fill the combobox with cities that match the
ZIP code.
problem is that some browser (mainly on MAC) don't let this to be done correctly. Also anti-popup program don't let either do this. So I'm
looking for creating a JS script, wich will be included in the page sent to the client (the browser) wich a structure giving the possibility to fill the combo by selecting a ZIP code in a text field. In my coutry, the same ZIP code may have many little town, so I've to take care at this problem.
So my problem is, depending on the ZIP code selected, fill the combo with possible town or cities accordingly, and then, when I submit the form,
save the RecordID (that is an unique code for the town). The structure of my table is:
columnA : recordID columnB : City columnC : Zip code
example: 1 Sion 1950 2 Chateauneuf 1950 3 Sierre 3960 4 Corin 3960 5 Monthey 4520 6 St-Maurice 4290
So, if a user enter 3960 in a text field, the JS script should fill the combo with Sierre and Corin. By selecting Sierre, I've to submit the RecordID 3 (that will be saved in the database), if the user selects
Corin, the RecordID would be 4
If you have any idea, please let me know.
Cheers,
Bob
JRS: In article <41************ *********@news. sunrise.ch>, dated Tue,
14 Sep 2004 12:01:22, seen in news:comp.lang. javascript, Bob Bedford
<be******@YouKn owWhatToDoHereh otmail.com> posted : I've a page where users may enter a zip code (text edit) and I want to fill a combobox with existing cities depending on the zip code entered.
Let give an example.
I've my text edit like: <input name="ZIP" type="text" id="ZIP" onKeyUp="fillci tycombo();"> <select name="City" id="City"></select>
When entering the zip code, I'd like the fillcitycombo() function to fill the combobox with the matching cities.
For that, every user, including those of dial-up and other slow links,
will have to download the whole list. It may well not be a good idea.
--
© John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.c om/faq/> JL/RC: FAQ of news:comp.lang. javascript
<URL:http://www.merlyn.demo n.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
"Bob Bedford" <be******@YouKn owWhatToDoHereh otmail.com> wrote in message news:<41******* **************@ news.sunrise.ch >... Hi,
It's what I'm looking for, but I've to generate the list with 4430 records, so I can't do it manually.
To get data, one possibility is to use a hidden iframe. What you do
is periodically load the iframe. Have the iframe invoke some
javascript in the onload handler. Have the javascript refresh the
page.
Here is a more detail write up: http://groups.google.com/groups?hl=e...news.xs4all.nl
From: Erwin Moller
Subject: Re: calling Perl script from javascript
Newsgroups: comp.lang.javas cript
Another alternative is to use an xml HTTP request. See: http://jibbering.com/2002/4/httprequest.html
I'd try to find a week long course on advanced web programming that
covers this stuff and convince your boss you need to attend.
Robert
> To get data, one possibility is to use a hidden iframe. What you do is periodically load the iframe. Have the iframe invoke some javascript in the onload handler. Have the javascript refresh the page.
Here is a more detail write up:
http://groups.google.com/groups?hl=e...news.xs4all.nl
I've been using this method until some users sent me an email saying that it
doesn't work on their browser. Anti-popup program blocks open windows, so I
can't get the result back.
From: Erwin Moller Subject: Re: calling Perl script from javascript Newsgroups: comp.lang.javas cript
Another alternative is to use an xml HTTP request. See:
http://jibbering.com/2002/4/httprequest.html
The reason I'm changing my code is that SAFARI isn't supported by some
features. and given what's written in the first part of the article, I won't
use this method.
Thanks anyway for the help.
On Thu, 16 Sep 2004 11:20:03 +0200, "Bob Bedford"
<be******@YouKn owWhatToDoHereh otmail.com> wrote: http://jibbering.com/2002/4/httprequest.html
The reason I'm changing my code is that SAFARI isn't supported by some features. and given what's written in the first part of the article, I won't use this method.
That warning on Safari is somewhat more severe than I've now found (I
don't have a Max OS-X about so it's based on 3rd hand info) there are
limitations, it is more limited than the other 2 implementations , but
it's completely usable.
Jim. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: srijit |
last post by:
Hello,
Here is an example code of xml writer in Python+PythonNet, Ironpython
and Boo. The codes look very similar.
Regards,
Srijit
Python + PythonNet:
import CLR
|
by: Mike McGee |
last post by:
I am new to database apps, but I am making a db with access 2002. Here is
what I have and what I would like for it to do.
tblCustomers = holds customer info (Name, Address, City, State, Zip, Phone)
tblzips = holds ( Zip codes, City, State, County, Country)
tblzips
ID Zipcode City State County Country
|
by: Sandy |
last post by:
Hello -
I need either a cheap tool or code & DB that calculates, eg. within 50-mile
radius of a zip code.
Anyone have any suggestions?
--
Sandy
|
by: dBNovice |
last post by:
Hi all, I am reusing code that was used in a previous copy of the DB.
I am trying to extract data from other tables, queries and a form and
put it in a table. The code was used previously and worked without any
problems. I am trying to figure out what is causing the problem. I
presume there is probably a missing reference but I can't tell. Parts
of the code works but it appears the following portion is not working.
'Action3: If the...
|
by: robinsand |
last post by:
Header File: car.h #if !defined CAR_H
#define CAR_H
enum TCarType { ctEconomy = 1, ctCompact, ctStandard, ctFullSize,
ctMiniVan, ctSUV };
class Car
{
public:
Car();
| |
by: help4me |
last post by:
I am having trouble updating a table. The logic seems so simple but I just can’t get it to work. The table is named test. The column names are passcode, name, address, city, state, zip and email.
First you have to sign into my site (name and passcode). This is a password protection page. The next php page holds the instructions to insert that data into the mysql table named test. At this time I am also inserting “fake data” into the...
|
by: TheDD |
last post by:
Hello world, I'm new to the community. I am a beginning programmer of java(well so far) and I got this programming class. I am seeking ideas and help.
Okay, I got this assignment. I need to make a contact list that has an output like this:
Name City Home Cell Type
Lisa Xiong Fresno 123-4567 987-5643 Friend
Cathy Vang Fresno 191-6573 987-1546 Contact
What I want is a column...
|
by: ravindarjobs |
last post by:
Hi friends,
i am progamming to generate UPS labels in asp.net 2.0
when i sent the follwoing xml request to UPS development server,
it say invalid licence code.
But indeed mine is original licence and it has worked fine with address validation perfectly, but why do i face problem doing access request.
<?xml version='1.0'?>
<AccessRequest xml:lang='en-US'>
|
by: mideastgirl |
last post by:
I have recently been working on a website for an honors association, and have a lot of difficulty but have found help from those on this site. I would like to see if I can get some more help on a different issue than what I was initially having.
I am working on storing data collected from a form on my website. I would like the information to be stored into MySQL once entered by users. I have googled this question and have tried multiple...
|
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...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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...
|
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...
|
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,...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |