custom form – Select all checkboxes depending on parent checkbox in SharePoint server 2016 on premise

I have a document library in SharePoint 2016 on-prem. The document library has a content type with columns that the user needs to complete when the user uploads a document. Since you cannot edit the document library form in InfoPath, I created a custom form based on the “editform.aspx” using SharePoint designer. I opened my new custom form in advanced mode and inserted the JavaScript. The form needs to have cascading dropdowns(which work perfectly) and auto check/uncheck multiple checkboxes based on the parent checkbox(select all functionality). I am using jQuery 3.4.1.min.js. Please see code below. I tried so many different ways, I could not get the checkboxes to check/uncheck automatically when the parent is checked. Your assistance will be highly appreciated.

<script type="text/javascript" src=""></script>
<script type="text/javascript" src=""></script>
<script type="text/javascript">
$(document).ready(function (){
relationshipList: "disciplinessub",
relationshipListParentColumn: "discipline",
relationshipListChildColumn: "Title",
parentColumn: "Discipline",
childColumn: "Sub discipline",
debug: true

$(document).ready(function () {
$('ctl00_ctl40_g_7a0cef3a_e14b_4ebe_80e8_b0c0c7b05b47_ff11_ctl00_ctl00').on('change', function () {
$('ctl00_ctl40_g_7a0cef3a_e14b_4ebe_80e8_b0c0c7b05b47_ff11_ctl00_ctl01').prop('checked', this.checked);
$('ctl00_ctl40_g_7a0cef3a_e14b_4ebe_80e8_b0c0c7b05b47_ff11_ctl00_ctl02').prop('checked', this.checked);
$('ctl00_ctl40_g_7a0cef3a_e14b_4ebe_80e8_b0c0c7b05b47_ff11_ctl00_ctl03').prop('checked', this.checked);
$('ctl00_ctl40_g_7a0cef3a_e14b_4ebe_80e8_b0c0c7b05b47_ff11_ctl00_ctl04').prop('checked', this.checked);
$('ctl00_ctl40_g_7a0cef3a_e14b_4ebe_80e8_b0c0c7b05b47_ff11_ctl00_ctl05').prop('checked', this.checked);

enter image description here