To answer my own question:
In my specific case I have projects with either one or two companies linked to every project.
In my form I can add a downloadable file to the project, but the download is for only one company.
So, in my form I have a select list where I choose the project first.
After I have chosen the project, I do an Ajax call retrieve the companies linked to the project and I insert these into the second field of the form, the select list where I can choose the company.
The JavaScript code to update the second select list (jform_company) is as follows:
jQuery(document).ready(function ($) {
$('#jform_project').on('change', function(evt, params) {
var pid = params.selected;
var url = "/media/com_docsafe/ajax/getcompanies.php?pid=" + pid;
$.getJSON(url, function(data) {
$("#jform_company").empty();
var newcompany = $("<option value=''>- Choose -</option>");
$("#jform_company").append(newcompany);
if (data.company1id) {
var newcompany = $("<option value='" + data.company1id + "'>" + data.company1name + "</option>");
$("#jform_company").append(newcompany);
}
if (data.company2id) {
var newcompany = $("<option value='" + data.company2id + "'>" + data.company2name + "</option>");
$("#jform_company").append(newcompany);
}
$('#jform_company').trigger('liszt:updated');
$('#jform_company').trigger('chosen:updated');
});
});
});
Op maandag 1 maart 2021 om 14:28:37 UTC+1 schreef René Kreijveld: