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.

Ganesh Sanap - MVP
  • 44,918
  • 21
  • 30
  • 61

1 Answers1

0

Try using this code in script editor web part:

<script type="text/javascript">
function runAfterEverythingElse(){
    // your code
    document.getElementById(id=&quot;Status_c15b34c3-ce7d-490a-b133-3f4de8801b76_$DropDownChoice_Aprovado&quot;).disabled = true;
    document.getElementById(id =&quot;Status_c15b34c3-ce7d-490a-b133-3f4de8801b76_$DropDownChoice_Rejeitada&quot;).disabled = true;
    document.getElementById(id=&quot;ctl00_ctl32_g_b2a57244_e74a_4dc6_90d1_809ce3ff419a_ctl00_toolBarTbl_RightRptControls_ctl00_ctl00_diidIOSaveItem&quot;).disabled = true;
    document.getElementById(id=&quot;ctl00_ctl32_g_b2a57244_e74a_4dc6_90d1_809ce3ff419a_ctl00_toolBarTbl_RightRptControls_ctl01_ctl00_diidIOGoBack&quot;).disabled = true;
}

_spBodyOnLoadFunctionNames.push(&quot;runAfterEverythingElse&quot;);

</script>

Make sure you are using correct selectors for your buttons.

Reference: Run Javascript after page loads

Ganesh Sanap - MVP
  • 44,918
  • 21
  • 30
  • 61