I have a dropdown field on a form and the options of the dropdown are hardcoded. I would like to disable one option out of three, based on a condition. The condition would be based on a field value on the form or a parameter passed in the url. Tried chatgpt, tried iris but to no avail. Here is the code below given by Iris:
// field id=“fieldkOGQ3JGNln”
const urlParams = new URLSearchParams(window.location.search);
const paramValue = urlParams.get(‘mo’);
const dropdown = document.getElementById(‘fieldkOGQ3JGNln’);
if (paramValue === ‘vj’) {
for (let i = 0; i < dropdown.options.length; i++) {
if (dropdown.options[i].value === ‘Non-Veg’) {
dropdown.options[i].disabled = true;
}
}
}
And yes, I m appending ?mo=vj to the url and refreshing the form.
Help on seeing this through, would be appreciated.