Jump to content

Reference a cascading dropdown to disable it with javascript


Recommended Posts

Hello,

I'm trying to reference a field, in a Details datapage, that is a cascading dropdown (the field is a text field called 'Area'). I need to disable it conditionally using javascript (I've found that when there are a lot of Rules it significantly slows the datapage loading compared to using js, so I need to use js to do this). 

I've been able to do this no problem with regular text fields and dropdowns but can't get it to read the cascading dropdown. I've been trying to use something like: 

var v_area = document.getElementsByName("EditRecordArea")[0]; 

along with the disable code in an if/then clause v_area.disabled=true;

Does anyone know how to alter the above to be able to use it in js? Many thanks!

Link to comment
Share on other sites

  • 3 weeks later...

Hi @DesiLogi,

It is possible with JavaScript to disable Cascading dropdown, however I would recommend using a Cascading TextField that has an option to disable the input field if only one option returned.

If my suggestion does not fit your workflow than you can use the following JavaScript:

<script>
document.addEventListener('DataPageReady', function (event) {
    const el = document.querySelector('select[id^="InsertRecordYOUR_FIELD"]');
    el.addEventListener('change', ()=>el.disabled="true");   
});
</script>

Regards,

vitalikssssss

Link to comment
Share on other sites

  • 1 month later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...