shane_spencer Posted December 6, 2023 Share Posted December 6, 2023 Hello! I am trying to hide an element on a page that will become visible only when Other is selected by a previous option. So far I haven't had any luck trying to input the following code on a code block on the page: <script> document.addEventListener('DOMContentLoaded', function() { // Add your logic here var previousOption = document.getElementById('select-2b0ae669-b004-4fdb-ade8-e90ac055f9b6-field'); var hiddenField = document.getElementById('text-e7dabace-7e8e-4ad6-a440-6aab243810c0-field'); // Initial state hiddenField.style.display = 'none'; // Event listener for changes in the previous option previousOption.addEventListener('change', function() { if (previousOption.value === 'Other') { hiddenField.style.display = 'block'; } else { hiddenField.style.display = 'none'; } }); }); </script> I'm not even sure if this is doing what I think it's doing, so any help would be appreciated! Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment