Forums

Enable/disabled fields dependent on dropdown selection

HCH 23 Jul, 2017
Hello,

I have the following requirement, but unfortunatly I have no idea how to solve it... Perhaps someone can give me some hints:

(A) I have a (customer) database table "sports_event" with the following columns:
- id
- event_name
- option_1
- option_2
- option_3

(B) In the first step I want to populate a dropdown box with the events, so the user can choose one event.

(C) Depending on the selection of the sports event in the dropdown box a input field, radio buttons and another dropdown box shall appear / disappear.

Suppose the following data in the database table:
=> 1 / event 1 / Y / N / Y
=> 2 / event 2 / N / N / N
=> 3 / event 3 / N / Y / Y
=> 4 / event 4 / Y / Y / N

If the user selects event 1 then:
- entryfield10 is visible and enabled
- radiogroup11 consists of radio box 1 and radio box 3 (but not radio box2)
- dropdown12 is visible and enabled

If the user selects event 2 then:
- entryfield10 is not visible and is disabled
- radiogroup11 consists of radio box 1 and radio box 3 (but not radio box2)
- dropdown12 is not visible and is disabled

If the user selects event 3 then:
- entryfield10 is not visible and is disabled
- radiogroup11 consists of radio box 1 and radio box 2 and radio box 3
- dropdown12 is visible and enabled

If the user selects event 4 then:
- entryfield10 is visible and enabled
- radiogroup11 consists of radio box 1 and radio box 2 and radio box 3
- dropdown12 is not visible and disabled


I know how to read data from a database table. If I use "return an array of key/value pairs..." as Select type in the Read Data event, then only two fields (e.g. id and event_name) can be used (Fields to retrieve) for filling the dropdown box. But I want to select all fields (using "all matching records" as Select Type in the Read Data event) when loading the form in order to have all data already in memory.

Now my questions:
[list=]
  • How selecting all fields of the database table (using "all matching records" as Select Type in the Read Data event) and populating dropdown box only with two of them (id, event_name)?

  • How to handle the additional fields (option_1, option_2, option_3) in order that they can control the other fields (entryfield10, radiogroup11, dropdown12), depending on the selection in the dropdown box?

  • [/list]

    Perhaps someone in the community can help me. I searched in the forum for similar solutions, but unfortunately I didn#t find some...

    Thanks for giving me some hints
    Hans-Christian
    Max_admin 23 Aug, 2017
    Answer
    Hello Hans-Christian,

    Apologizes for the late reply!

    You can do this in 1 of 2 ways:

    #1- use the "Reload" event to build and load the desired fields section, you can find how to do this in the v6 manual.

    #2- wait for the next Chronoforms update and use the enhanced field events section to do this on the form directly (easier).

    Best regards,
    Max
    Max, ChronoForms developer
    ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
    ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
    HCH 23 Aug, 2017
    Hello, thanks for your message. I will wait for the next Chronoforms update 😀
    Max_admin 03 Sep, 2017
    Hello Hans-Christian,


    How selecting all fields of the database table (using "all matching records" as Select Type in the Read Data event) and populating dropdown box only with two of them (id, event_name)?


    You do this using PHP, and you will need to extract the correct info for the dropdown, or you can just run 2 "read data" actions, this is the only way to do it now.

    With the latest update you can now target multiple fields with the same event, so the 2nd question should be easier to do.

    Best regards,
    Max
    Max, ChronoForms developer
    ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
    ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
    This topic is locked and no more replies can be posted.