TOPIC:

Select cities by country 5 years 4 months ago #206654

  • sciencemkt's Avatar Topic Author
  • sciencemkt
  • Offline
  • Premium Member
  • Premium Member
  • Registered
  • Science applied to marketing
  • Posts: 307
  • 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 Company

=============================================

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

Select cities by country 5 years 4 months ago #206694

  • marko.bosnjak
  • Offline
  • User is blocked
  • User is blocked
  • Registered
  • Posts: 2222
  • Thanks: 280
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 5 years 4 months ago #206698

  • sciencemkt's Avatar Topic Author
  • sciencemkt
  • Offline
  • Premium Member
  • Premium Member
  • Registered
  • Science applied to marketing
  • Posts: 307
  • Thanks: 0
It worked perfectly. :)

Thank you very much.
Alejandro Cobo
Neuromarketing Company

=============================================

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

Select cities by country 5 years 4 months ago #206699

  • marko.bosnjak
  • Offline
  • User is blocked
  • User is blocked
  • Registered
  • Posts: 2222
  • Thanks: 280
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 3 years 2 weeks ago #239165

  • 1987Jan
  • Offline
  • Premium Member
  • Premium Member
  • Registered
  • Posts: 212
  • Thanks: 1
Wie geht der Code mit einer dritten Auswahlliste? (Strassen)?

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

Select cities by country 3 years 2 weeks ago #239171

  • mihaela
  • Offline
  • User is blocked
  • User is blocked
  • Registered
  • Posts: 3128
  • Thanks: 416
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.061 seconds

Support Discord

Join our Discord and enter the Crosstec channels for live-support, chat forums and directly interacting with the community!

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

Subscribe to news and updates!

Special Offer

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!

Live Support Chat Opened!

Join our Discord chat here and enter the Crosstec channels to receive live support and talk directly to the team!