1

In the script editor I have this code to disable some buttons:

<script>
document.getElementById(id="Status_c15b34c3-ce7d-490a-b133-3f4de8801b76_$DropDownChoice_Aprovado").disabled = true;
document.getElementById(id ="Status_c15b34c3-ce7d-490a-b133-3f4de8801b76_$DropDownChoice_Rejeitada").disabled = true;
document.getElementById(id="ctl00_ctl32_g_b2a57244_e74a_4dc6_90d1_809ce3ff419a_ctl00_toolBarTbl_RightRptControls_ctl00_ctl00_diidIOSaveItem").disabled = true;
document.getElementById(id="ctl00_ctl32_g_b2a57244_e74a_4dc6_90d1_809ce3ff419a_ctl00_toolBarTbl_RightRptControls_ctl01_ctl00_diidIOGoBack").disabled = true;
</script>

However, in the browser console, I can get the expected result, but when I run it inside the script editor, nothing happens.

3
  • Are you using classic experience pages in SharePoint online? Commented Sep 21, 2021 at 15:46
  • I'm using the classic experience. Thank you, this solution worked! Commented Sep 21, 2021 at 16:25
  • Try code given in my answer below & let me know if it works for you. Commented Sep 21, 2021 at 16:26

1 Answer 1

0

Try using this code in script editor web part:

<script type="text/javascript">

    function runAfterEverythingElse(){
        // your code
        document.getElementById(id="Status_c15b34c3-ce7d-490a-b133-3f4de8801b76_$DropDownChoice_Aprovado").disabled = true;
        document.getElementById(id ="Status_c15b34c3-ce7d-490a-b133-3f4de8801b76_$DropDownChoice_Rejeitada").disabled = true;
        document.getElementById(id="ctl00_ctl32_g_b2a57244_e74a_4dc6_90d1_809ce3ff419a_ctl00_toolBarTbl_RightRptControls_ctl00_ctl00_diidIOSaveItem").disabled = true;
        document.getElementById(id="ctl00_ctl32_g_b2a57244_e74a_4dc6_90d1_809ce3ff419a_ctl00_toolBarTbl_RightRptControls_ctl01_ctl00_diidIOGoBack").disabled = true;
    }

    _spBodyOnLoadFunctionNames.push("runAfterEverythingElse");

</script>

Make sure you are using correct selectors for your buttons.

Reference: Run Javascript after page loads

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.