Hi, I have 2 dropdowns, with same values read from a db table. When I select an option from the first one, I should like to have the same option disabled (or removed) in the second dropdown.
I tried something like this:
$('select[name=first]').on('change', function() {
var self = this;
$('select[name=second]').find('option').prop('disabled', function() {
return this.value == self.value
});
});
where first and second are names of dropdowns, but it doesn't work ...
Any suggestion?
Thank you
Alex
this code uses jQuery but v8 does not use jQuery, so unless your page has jQuery loaded then it will not work, you can check the browser's console for errors
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Hi Max, to load jquery I have a php action including:
use Joomla\CMS\Factory;
$wa = Factory::getApplication()->getDocument()->getWebAssetManager();
$wa->useScript('jquery');
In the console I have no errors.
Thank you
Alex
ok, does the change event fire in your code ? I think your code should be inside a document ready event for it to work
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
what happens when the user "unselects" an option from the first one ? will this readd the option to 2nd one ?
I think that you better use 2 radio groups or checkboxes groups, that will be easier to "hide" and show
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.