TOPIC:

Select cities by country 2 years 11 months ago #206654

  • sciencemkt's Avatar Topic Author
  • sciencemkt
  • Offline
  • Senior Breezer
  • Senior Breezer
  • Posts: 132
  • Thanks: 0
Hello,

I would like to know how you can do so that when you select a country, the cities of that country appear.

For example:
  • If the US is selected, the cities across the US should appear.
  • If you select Germany, you can see the cities of Germany.

Thank you.
Alejandro Cobo
Neuromarketing consultant

==============================================
Like us on Facebook:
www.facebook.com/AlejandroCobo.Neuromarketing
==============================================
Blog:
www.alejandrocobo.com
==============================================

Please Log in or Create an account to join the conversation.

Select cities by country 2 years 11 months ago #206694

  • marko.bosnjak
  • Offline
  • User is blocked
  • User is blocked
  • Posts: 2222
  • Karma: 44
  • Thanks: 279
Hello,

I've created an example for you.
Create 2 select lists. The first should be named "country" and the second "city". The first has values:
1;Select Country;none
0;USA;usa
0;Germany;germany
The second list has only "0" inserted.
Now go to the "country" element > Advanced tab > Actionscript > Type > Custom > Actions > Change and use this code in the framework:
function ff_country_action(element, action)
{
    var city = ff_getElementByName('city');

    var usaArray = new Array(
        'New York', 'Los Angeles', 'Chicago', 'Houston', 'Phoenix', 'Philadelphia',
        'San Antonio', 'San Diego', 'Dallas', 'San Jose', 'Austin', 'Denver',
        'Las Vegas', 'Seattle', 'Miami', 'Washington', 'Sacramento', 'Other'
    );
    var germanyArray = new Array(
        'Berlin', 'Frankfurt', 'München', 'Köln', 'Frankfurt am Main', 'Stuttgart',
        'Düsseldorf', 'Dortmund', 'Essen', 'Leipzig', 'Bremen', 'Other'
    );
    if (element.value == 'none') {
        // drop cities
        while (city.options.length > 0)
            city.options[city.options.length-1] = null;
    } else {
        // get the matching array
        var selectedArray = eval(element.value+'Array');

        // drop supernumerous option
        while (selectedArray.length < city.options.length-1)
            city.options[city.options.length-1] = null;

        // add the new options
        city.options[0] = new Option('Select City', 'none', true, true);
        for (var i=0; i < selectedArray.length; i++)
            city.options[i+1] =
                new Option(selectedArray[i], selectedArray[i]);
    }
}
Simply add more cities in the arrays between single quotes.
I will attach you the form. Install it and test it out.

Regards,
Marko
======================================
Support Crosstec and get ALL EXTENSIONS and professional support for just $5
Here!
======================================
Need to renew Pro Support?
Buy Here!
======================================
Satisfied?
Consider a Membership!
======================================
Follow us on Facebook!
Attachments:
The following user(s) said Thank You: sciencemkt

Please Log in or Create an account to join the conversation.

Select cities by country 2 years 11 months ago #206698

  • sciencemkt's Avatar Topic Author
  • sciencemkt
  • Offline
  • Senior Breezer
  • Senior Breezer
  • Posts: 132
  • Thanks: 0
It worked perfectly. :)

Thank you very much.
Alejandro Cobo
Neuromarketing consultant

==============================================
Like us on Facebook:
www.facebook.com/AlejandroCobo.Neuromarketing
==============================================
Blog:
www.alejandrocobo.com
==============================================

Please Log in or Create an account to join the conversation.

Select cities by country 2 years 11 months ago #206699

  • marko.bosnjak
  • Offline
  • User is blocked
  • User is blocked
  • Posts: 2222
  • Karma: 44
  • Thanks: 279
Awesome!
I'm glad it's working for you.
Let us know if you have more questions.

Regards,
Marko
======================================
Support Crosstec and get ALL EXTENSIONS and professional support for just $5
Here!
======================================
Need to renew Pro Support?
Buy Here!
======================================
Satisfied?
Consider a Membership!
======================================
Follow us on Facebook!

Please Log in or Create an account to join the conversation.

Select cities by country 6 months 4 weeks ago #239165

  • 1987Jan
  • Offline
  • Senior Breezer
  • Senior Breezer
  • Posts: 88
  • Thanks: 0
Wie geht der Code mit einer dritten Auswahlliste? (Strassen)?

Please Log in or Create an account to join the conversation.

Select cities by country 6 months 4 weeks ago #239171

  • mihaela
  • Offline
  • Developer
  • Developer
  • Posts: 3128
  • Karma: 105
  • Thanks: 415
Hello,

Similar to setting the possible cities for a specific country, where you write Actionscript in the city element, you have to write an Actionscript in the city select list to fill in the possible road options depending on which city is selected.

I hope this explanation helps.

Regards,

Mihaela

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
  • 2
Moderators: ForumSupport
Time to create page: 0.053 seconds

BreezingForms Pro 1.4.7 for WordPress Released!

Available in the membership section.

Summer Sale!

Massive discounts on all subscriptions!

Get Your Subscription Here

Quick Links

Downloads

BreezingForms

ContentBuilder

BreezingCommerce

Templates

Documentation

BreezingForms

ContentBuilder

BreezingCommerce

Apprendre BreezingForms (French Community)

Apprendre et maîtriser BreezingForms par des tutoriels et exemples, le tout en français

breezingforms.eddy-vh.com

Questions et réponses sur les forums de l'AFUJ

AFUJ

Special Offer

Summer Sale! All subscriptions at a special price!

Includes prio support, all of our current and future Joomla!® extensions and Joomla!® templates for the duration of your membership.

Get it from here

3rd Party Discount - 25% Off

We help you to keep your costs under control. If you are a new member and purchased a form building tool from a different form vendor, then you'll get a 25% discount on our subscription plans.

How to receive the discount:

Send us a quick email to sales@crosstec.org with a proof of purchase (for example a paypal receipt), await payment instructions and enjoy your membership!