How do you define the value of a drop-down list from the selection of another list?

RobertG

Member
Hi,

I have a dropdown list with some choices. Some rows contain "No accommodation".
I have another dropdown list with accommodations choices. One of them is "NO ACCOMMODATION".
I would like to automatically select this choice when the first list selected row contains "No accommodation".
I tried with PHP and JS, but I failed.
Could you tell me how to do?

Both lists are databasejoin elements
 
Last edited:
Thanks troester,

But I dont' want to only display the "NO ACCOMMODATION" row in the second dbjoin list, but automatically select it, and perhaps disable the list, and enable it when another row (without "no accommodation") is selected in the first list.
Actually, the where clause of the second is "where active = true".

For example, I select in the first dbjoin element (hr5i3_fb_stay___id_french_course) the row "TEENAGERS (15/18) 10 lessons/week (No accommodation)" and I would like to automatically select "NO ACCOMMODATION" in the dbjoin element "hr5i3_fb_stay___id_accommodation".

To disable the second list, I failed with JS and didn't find how to disable, enable, hide, etc. an element with PHP or inline JS script (not a predefined action in the JavaScript tab).
I tried with a calc element to read and search for "No accommodation" in the selected row and used a JS action
Code:
on change : When this element "sel_french_course" == "No accommodation", disable element "hr5i3_fb_stay.id_accommodation"
but it doesn't work (see the attachment).
The calc element is using that PHP calculation (it observe '{hr5i3_fb_stay___id_french_course}' and works fine:
Code:
if (empty('{hr5i3_fb_stay___id_french_course}'))
{
$rest = 'MANDATORY' ;
} else {
if (str_contains('{hr5i3_fb_stay___id_french_course}','No accommodation')){
$rest = 'No Accommodation';
} else {
$rest = '{hr5i3_fb_stay___id_french_course}';
}
}
return $rest;
Is it possible in this code, when the value is "No accommodation", to define in the accommodation element either the "NO ACCOMMODATION" row or the "Veuillez choisir" row, then disable the accommodation dbjoin element, and enabled it if the value of the calculated field is not "No accommodation"?
 

Attachments

  • Capture d’écran 2023-07-27 083250.png
    Capture d’écran 2023-07-27 083250.png
    44.5 KB · Views: 50
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top