Support » Allgemeine Fragen » Conditional Fields depending on checkboxes

  • I’m currently trying the following (simplified objects):

    I have a bunch of „objects“, which are cities. Each city has a relating country (even though I’m not sure how to implement this relation, yet), so for example I have the following cities:

    Stuttgart - Germany
    Berlin - Germany
    Dresden - Germany
    Paris - France
    Marseille - France
    Lyon - France
    New York - USA
    Chicago - USA
    LA - USA
    Miami - USA
    Peking - China
    Shanghai - China
    Hongkong - China

    I think you get what I mean.

    Additionally, I have some checkboxes, including the country, so in the case of the list provided, I would 4 checkboxes, one for Germany, one for France, one of USA and one for China.

    When ticking one of this checkboxes, the relating cities should appear underneath, when ticking two of the checkboxes, the cities of both checked countries should appear, and so on.

    Actually, I have no idea how to get this started. In a normal web application, I would just create a database table with 3 columns (ID, City, Country) and then in my frontend just react on the checkbox.change, send AJAX to a php file, which gets the requested objects from database (something like select * from tbl_cities where country=germany) and just echo them.

    Is something similar possible in WordPress? Are there plugins for things like that, or how could I get this started?

    To clarify, it’s html that should be displayed then, like a list or something, so if selecting germany, I would have something like a <ul> with foreach($cities as $c){ echo "<li>".$c."</li>";}, but I need the thing around, how do I get the cities and how do I react on the checkboxes and where do I store cities and countries

Ansicht von 1 Antwort (von insgesamt 1)
Ansicht von 1 Antwort (von insgesamt 1)
  • Das Thema „Conditional Fields depending on checkboxes“ ist für neue Antworten geschlossen.