Hi,
I am using a modal dialog lookup with select.
The lookup fields are:
Display field #1: ks_stelle
Display field #2: ks_la
Display field #3: Jahr
Display field #4: ks_gueltig
The database values of ks_gueltig are 0 or 1.
The shown values are No for 0 and Yes for 1...
I am trying to disable the options with ks_gueltig == 0.
I should show all options but the options with ks_gueltig == 0 should NOT be selectable.
I used the following code in "startup script" but have no success.
Any idea where to start?
Startup Script
$(document).on("shown.bs.modal", function(event) {
var modal = $(event.target); // Get the modal that was just shown
// Check if it's the modal lookup (based on modal title or other unique properties)
if (modal.find(".modal-title:contains('Lookup')").length) {
// Target the select dropdown inside the modal (adjust #your_field_id to your field's actual ID)
var select = modal.find("select#x_Kostenstelle");
// Loop through each option in the select dropdown
select.find("option").each(function() {
var option = $(this);
var ks_gueltig_value = option.data("ks_gueltig"); // Assuming ks_gueltig value is passed as data attribute
// Disable option if ks_gueltig is 0
//if (ks_gueltig_value == 'No') {
option.prop("disabled", true); // Disable the option
option.css("color", "#999"); // Change color to indicate it's disabled
//}
});
}
});
mpol_ch