I have created two lookup fields in formidableforms, in lookup 1 you choose the location and in the second field (lookup 2) there are working types, you can choose multiple work types per location, but sometimes there is only 1 choice. Is it possible that when there is only one choice that is directly visible instead of that I have to select it manually?
I have tried with some Javascript, is that the right way?
I received your reply through email. I'm reposting it here for reference:
"Hello Victor, first of all thank you very much for youre reaction, I made this script en put this in a html field in the used form:
(function initRepeaterLogic() { const locatieVelden = document.querySelectorAll('[id^="field_1897-"]'); locatieVelden.forEach(function(locatieVeld) { locatieVeld.addEventListener('change', function () { const veldIndex = locatieVeld.id.split('-')[1]; const werksoortVeld = document.getElementById('field_1898-' + veldIndex); setTimeout(function () { if (werksoortVeld && werksoortVeld.options.length === 2) { werksoortVeld.selectedIndex = 1; werksoortVeld.dispatchEvent(new Event('change', { bubbles: true })); } }, 600); }); });})();
It does nog work right now. I am in doubt of the field ID's. Can you look at this script, am i on the right track?
Best regards,
Piet Boekema"
"I am in doubt of the field ID's."
So am I!
Formidable forms field ids by "field_" + [key]. Unless, you changed the field hey to be numeric, they are not formatted correctly. Use your browser's inspection tool to see what the field #'s are truly.