How to create a country and state combobox

This is a discussion on "How to create a country and state combobox" within the Flash & Multimedia Forum section. This forum, and the thread "How to create a country and state combobox are both part of the Design Your Website category.



Go Back   Webforumz.com > Main Forums > Design Your Website > Flash & Multimedia Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Jul 26th, 2007, 06:51
Junior Member
Join Date: Jul 2007
Location: Malaysia
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Unhappy How to create a country and state combobox

Hi! I'm currently creating a website which need the user to fill in a form that have country and state. I would like to create a combobox for it. The user should choose their country 1st before the state. Once they had choose theiy country, the state combobox will appear and show a list of all the state base on the country.

However, I do not have any experience in create combobox before. I do find for the example and other source from internet, but I found that they are too complex and hard for me to understand.

Do anyone know where can I find a more simple tutorial that show how to create combobox step by step? And is it possible to create the combobox only in flash? without using other programme such as php or asp...

Last edited by Learner; Jul 26th, 2007 at 07:02.
Reply With Quote

  #2 (permalink)  
Old Jul 26th, 2007, 15:19
Multimedia Specialist
Join Date: Apr 2007
Location: Arizona
Age: 25
Posts: 666
Blog Entries: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Sgaspar11
Re: How to create a country and state combobox

Well, this is by no means something that is "easy" it'll take some thought around how you would want this to look.

Flash has a components window that will automatically let you create combo boxes and list specific values.

You could create a combo box with an instance name of "Country" which lists all of your countries. And one for each country which lists the states. (i.e. USA_states)

Set all of the state combo boxes to visible = false.

Then, use some actionscript to say if "country" = USA, then make the USA_states combo box visible and so on for each country.

I'm not sure of any tutorials, but give this idea I try and we can walk you through any issues you might have.
Last Blog Entry: Yay!? (Oct 8th, 2007)
Reply With Quote
  #3 (permalink)  
Old Jul 27th, 2007, 02:47
Junior Member
Join Date: Jul 2007
Location: Malaysia
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Re: How to create a country and state combobox

Thanks for your reply.
Well I found the components that you mentioned which create the combobox automatically and i got a code from other source which I think is more simple and I can understand abit and the original file is look like this.

Code: Select all
//
//Populate ISO Country Codes & US States in Combo Box
//
countries = "Andorra, Principality of  |United Arab Emirates|Afghanistan, Islamic State of|Antigua and Barbuda |Anguilla|Albania|Armenia|Netherlands Antilles|Angola |Antarctica |Argentina  |Old style Arpanet|American Samoa|Austria|Australia  |Aruba  |...";
countrycodes = "AD|AE|AF|AG|AI|AL|AM|AN|AO|AQ|AR|ARPA|AS|AT|AU|...";
usstates = "none|AL|AK|AZ|AR|AP|CA|CO|CT|DE|DC|FL|GA|HI|ID|...";
aISOCountries = countries.split("|");
aISOCountryCodes = countrycodes.split("|");
aUSStates = usstates.split("|");
//Populate Combo Box
for (i=0; i<aISOCountries.length; i++) {
 cbCountry.addItemAt(i, aISOCountries[i], aISOCountryCodes[i]);
}
//USA = 234
cbCountry.setSelectedIndex("234");
// sort the list
cbCountry.sortItemsBy("Label", "ASC");
//Populate Combo Box
for (i=0; i<aUSStates.length; i++) {
 cbUSState.addItemAt(i, aUSStates[i], aUSStates[i]);
}
// Sort the List
cbUSState.sortItemsBy("Label", "ASC");
cbCountry.setChangeHandler("sendCountryToTextBox")
cbUSState.setChangeHandler("sendStateToTextBox")
function sendCountryToTextBox() {
 _root.txtCountry = "country = "+cbCountry.getValue();
}
function sendStateToTextBox() {
 _root.txtState = "state = "+cbUSState.getValue();
}
I'm not so profesional i using the actionscript. From this code, the thing that I know is where to change the country and state. But the states is showing all the time, not shown base on the country that the user select.
Can anyone edit it for me or have any other suggestion code for this combobox?
Attached Files
File Type: swf cbCountry.swf (82.6 KB, 41 views)
Reply With Quote
  #4 (permalink)  
Old Jul 27th, 2007, 17:05
Multimedia Specialist
Join Date: Apr 2007
Location: Arizona
Age: 25
Posts: 666
Blog Entries: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Sgaspar11
Re: How to create a country and state combobox

Can you post the .fla and I will mess around with it a bit over this weekend.

You should be able to use some if/then statements to make this work properly.
Last Blog Entry: Yay!? (Oct 8th, 2007)
Reply With Quote
  #5 (permalink)  
Old Jul 30th, 2007, 01:59
Junior Member
Join Date: Jul 2007
Location: Malaysia
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Re: How to create a country and state combobox

Sorry for reply late.
I had attach the fla file. Thank for your help in advance!
Attached Files
File Type: fla cbCountry.fla (389.5 KB, 37 views)
Reply With Quote
Reply

Tags
combobox

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
combobox ahwell Flash & Multimedia Forum 3 Jan 25th, 2008 10:53
combobox component ahwell Flash & Multimedia Forum 0 Sep 11th, 2007 17:21
SEO for your country Pádraig Search Engine Optimization (SEO) 5 Jul 18th, 2007 16:19
Country, postcode etc - mysql tables jimz Databases 2 Jan 30th, 2007 17:02
A simple QUES : Host from which country is the best ? amandeep Hosting & Domains 3 May 29th, 2006 10:31


All times are GMT. The time now is 14:57.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43