Hi sorry about that, thought I had attached a screenshot of the editor. Not sure if I’m doing this currently or if I followed your instructions precisely. Let me know if the attached screenshot helps.
No. The selector should be “first-child”. No such selector (by select plain text of options) (Your syntax is wrong). Set Your first child with the text “how you find us”.
<script>
// Get the entire dropdown via ID
let selectionDropdown = document.getElementById("selection-dropdown");
// Now get its options
let selectionOptions = selectionDropdown.getElementsByTagName("option");
// Disable the first one. Make sure that you set the first one as the "read-only" option in the
// Webflow-UI
selectionOptions[0].disabled = true;
</script>
I know the request is for disable but I prefer to use hidden because the user will only see valid options the downside is it will force a value once you select an option; depending on your needs this can be a bonus.
This script target multiple selectors instead of one by one.
<script>
/*****************
Suggests to use an id for the main form, so your scope applies only this form.
If not use only "select"
*****************/
let selects = document.querySelectorAll("#your-id-form select");
selects.forEach((select) => {
let options = select.getElementsByTagName("option");
options[0].hidden = true;
});
</script>
This is vanilla javascript but you can use jQuery also.
I’ve used this, and it works for me, but only if it’s only for the first form on the page.
I’ve created separate entries for the other forms, but it only works on whichever is first.
I’ve cleaned up the code provided by @RaulRueda. Now it will target select fields using a data attribute instead of an ID. You’re not supposed to have more than one of the same ID, but you can have as many duplicate attributes as you want
Here’s a link to the project:
And then to the MemberScript #49 to copy the code.
And finally a tutorial. It’s only 44 seconds long