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

I need three sequential drop box menus

14
Desired result:

Click Select Country and have a drop menu open that lists all of the world's countries.

Select a Country from that list and have another drop menu then open that lists all of the provinces/states in that country.

Select a Province/State from that list and have another drop menu then open that lists the cities in that Province/State.

Selecting a City will open a new web page with information from that City.

At the moment I am populating three tables using Access on my computer here in Vancouver. They are Countries - Province/State - Cities. The Countries table contains the country name and the 2-letter FIPS code. The Province/State table contains the province/state name and the 3-letter Region Code as well as the 2-letter FIPS code. The codes in both cases are unique. Once the three tables have been fully populated, I will be running a program that will convert them to MySQL while transferring them to my server in California.

I am fairly conversant with Access, and am not having a problem there, but I'm not at all familiar with MySQL. Can anyone point me to coding that will accomplish what I need with those drop menus? I also need a plain English description of how to point the menus to the correct tables. I am also quite conversant with HTML coding, subject to it not getting too exotic.

My apologies in advance if this type of problem has been previously posted here, but I could find nothing in my search.
Aug 14 '10 #1

✓ answered by TheServant

Sounds simple enough.

Have a look here to see a script written in javascript which does part of what you're after.

Now what you have to do is instead of the hard coded list in that example, you have it check your database for the list. I suggest doing a MySQL tutorial to get familiar with how to retrieve data.

15 3616
TheServant
1,168 Expert 1GB
Sounds simple enough.

Have a look here to see a script written in javascript which does part of what you're after.

Now what you have to do is instead of the hard coded list in that example, you have it check your database for the list. I suggest doing a MySQL tutorial to get familiar with how to retrieve data.
Aug 16 '10 #2
Gowisha
14
Thank you for pointing me to that script. As you have guessed, my biggest problem is figuring out how to have a script such as that, bring up the data in my Access database (3 separate tables). I'll take your suggestion vis-a-vis the MySQL tutorial, but first I need to have it bring up the Access tables. However, you have given me some good guidance here, and I thank you for that.
Aug 16 '10 #3
TheServant
1,168 Expert 1GB
No problem, let us know how you go, and come back if you have problems with your own script.
Aug 16 '10 #4
Gowisha
14
Done, and it works fine. However, I have just been informed that my web site host does not allow JavaScript files, unless I pay extra. I'm now trying to figure out if I can directly convert the entire .js file into either a .html or .php file. Fun, fun, fun...
Aug 25 '10 #5
TheServant
1,168 Expert 1GB
That sucks.

You can run javascript in the body of your HTML. There are several reasons this is not encouraged (caching, separation of structure, etc.), but it looks like your only option.
Basically you just encapsulate what was in the .js file with:
Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript" language="javascript">
  2.    .js file contents go here
  3. </script>
And then put that in your <body> tag in your HTML. Preferably at the botton, directly before </body>.

Let us know if you have any problems with that.
Aug 25 '10 #6
Gowisha
14
Thanks for the suggestion. I did that, but my selection boxes are now non-operational. All three are very small boxes and not selectable. Just to make sure I did this correctly, I opened the .js file in Notepad, and copied the entire contents. I then plugged in the brief script you suggested, with the .js contents pasted in where you indicated. Is it possible that the 'Form' coding needs adjusting? It is:

<form>
<table border="0">
<tr>
<td>
<select id='countrySelect' name='country' onchange='javascript: populateState(); populateCity();'></select>
</td>
<td>
<select id='stateSelect' name='state' onchange='javascript: populateCity();'></select>
</td>
<td>
<select id='citySelect' name='city'></select>
<script type="text/javascript">initCountry('CA'); </script>
</td>
</tr>
</table>
</form>

And now I'm signing off for the night (I'm Vancouver time). Thanks again for your ongoing help!
Aug 25 '10 #7
Gowisha
14
You can see the developing site here:

http://capsulecomments.com/
Aug 25 '10 #8
TheServant
1,168 Expert 1GB
You don't need to say it's javascript here:
Expand|Select|Wrap|Line Numbers
  1. onchange='javascript: populateCity();'
  2. Can just be:
  3. onchange="populateCity();"
  4.  
Also, in you country dropdown you call populateCity() twice.

I don't think either of those will be the problem, but I will have a closer look a bit later.
Aug 25 '10 #9
Gowisha
14
All three of the drop down boxes worked fine prior to my plugging the .js file into the html body. They showed all the countries and allowed a selection. The code populated the State drop down box and let the user select a city. Normally when a City is selected, a html page opens. If there is no html page for a selected city, nothing further happens when you click on the City name.

I guess the bottom line here is that the .js script works fine here on my computer, using it as a separate file (not embedded in the home page). I have the same problem here after plugging the .js into the home page, in that the drop down boxes no longer function, and they are truncated in length. So, I think we can agree that the two items you pointed out are not the cause of this. I'm still parsing the coding, line by line where it sits in the body of the home page.

But, thanks for the comments; they are appreciated.
Aug 25 '10 #10
Gowisha
14
I removed <script type="text/javascript" src="yourFileName.js"></script> from the <head> section of the web page, but that made no difference. In the main .js script there is the following.

("id","citySelect");
inputSel.setAttribute("onchange","java_script: if

(this.selectedIndex!=0)

{window.location='/capsulecomments.com/' + (this.options

[this.selectedIndex].text) + '.html';}");

I assume that the /capsulecomments.com/ is no longer relevant, as the .js is within the html body. Ergo, to what and how should that be changed?
Aug 26 '10 #11
Gowisha
14
Update: I have removed the <head> .js script reference, and have changed the previous message coding to:

inputSel.setAttribute("onchange","java_script: if (this.selectedIndex!=0) {window.location='' + (this.options[this.selectedIndex].text) + '.html';}");

The change is {window.location='' instead of having 'capsulecomments' in there. Everything works as it should with one exception. The drop down box for City does not populate, and also is now writeable. If I type in the City, say Vancouver, nothing happens. So I am assuming that the final problem lies with the same question as before. What should be in that line?
Aug 27 '10 #12
Gowisha
14
Sorry, I should have mentioned that the .js code is now within the html <body> and works, with the above exception. It no longer points to an outside .js file.
Aug 27 '10 #13
Gowisha
14
I give up! When I remove the outside javascript, the html page then fails to present the drop down boxes. I am going to bite the bullet and pay Lunarpages the extra monthly fee to let the javascript run on the server. Thanks for all of your assistance, I really do appreciate it.
Aug 27 '10 #14
TheServant
1,168 Expert 1GB
I suggest you should post the Javascript problem in the Javascript forum. I think the experts over there will have more of an idea than me with regards to workarounds. Is that one of Lunar Pages express/lite plans? I have an account with them using a small plan, but not the smallest and I can host .js files.
Aug 27 '10 #15
Gowisha
14
Thanks, good idea and I'll be doing just that. I'll let you know what they come up with (if anything). Meanwhile I've posted the web page at www.capsulecomments.com and the .js script is embedded in the web page. If I post the .js script as a separate file and point to it, all is well, but embedded does not work. C'est la vie.
Aug 29 '10 #16

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Davmagic .Com | last post by:
Where can I find a simple, secure Perl script to run my Drop Downs on my pages? Using Unix... TIA Web Design, Magic, Painting, Junking, More http://www.davmagic.com Paint A House...
2
by: delerious | last post by:
I'm going to build a vertical navigation menu using images in HTML. I want to have a drop-down menu appear next to an image when I move the mouse over it. I know that I could just download any one...
2
by: Joey Liang via DotNetMonster.com | last post by:
Hi all, I am new in asp.net, i encounter some problems in using drop down list and datagrid. I have manage to bind the data into datagrid but i wanted to bind the data into the datagrid accroding...
6
by: Joey Liang via DotNetMonster.com | last post by:
Hi all, I have a drop down list which store all the different brands of product.When i selected the particular brand from the drop down list, it will display all the products with the selected...
1
by: ashok76 | last post by:
Hi I've a DataGridView and where has column 0 is a DataGridViewComboBoxColumn Whenever I selected that cell then the drop down list not appeared on single click event hence I need to click again...
2
by: masker | last post by:
I was on the web trying to find a javascript that would allow me to input a number on my website and have it increase by a given percentage every second. During my search I found the Earth...
5
by: trint | last post by:
I have a datagridview which must have 3 textbox's in a single cell per row: textbox1 for Length textbox2 for Width textbox3 for Height Any help is very much appreciated. Thanks, Trint
5
by: rodeoval | last post by:
I need to have three drop down lists, but the dependent should get the values from the database without refreshing the page..If knows,someone pls reply soon
0
by: aboutjav.com | last post by:
Hi, I am new at asp.net and want to add a horizontal dropdown menu like toolstripmenu in windows form. I found a drop down menu written in javascript (DHTML). How do I add to my asp.net project....
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
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: 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...
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...

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.