Написал скрипт для нескольких разделов CRM (контакты, сделки, компании). Сам скрипт работает нормально, кроме раздела компании, выдает такую ошибку TypeError: document.querySelector(...) is null. В скриптах не особо разбираюсь, так что буду рад помощи. Работа скрипта заключается в отображении разделов на странице в зависимости какой тип компании выбран. Собственно сам скрипт:
BX.ready(
function()
{
document.querySelector('select[name="TYPE_ID"]').addEventListener('click', checkFields);
checkFields();
function checkFields() {
var curr_type_id = document.querySelector('select[name="TYPE_ID"]').value;
//Секция ТО/ТА
var tota_section = document.querySelector('#section_uvae8ag2_contents');
tota_section.style.display = 'none';
//Секция другие агенства
var other_section = document.querySelector('#section_0klk6s3p_contents');
other_section.style.display = 'none';
//Секция корпорации
var corporation_section = document.querySelector('#section_uuoznr1l_contents');
corporation_section.style.display = 'none';
//Секция партнеры
var partner_section = document.querySelector('#section_ho7cg3pr_contents');
partner_section.style.display = 'none';
//Секция поставщики
var supplier_section = document.querySelector('#section_ivsm7zk8_contents');
supplier_section.style.display = 'none';
//Секция конкуренты
var competitor_section = document.querySelector('#section_wkdsoedr_contents');
competitor_section.style.display = 'none';
//Секция СМИ
var smi_section = document.querySelector('#section_pbtccphg_contents');
smi_section.style.display = 'none';
//Секция подрядчики
var contractor_section = document.querySelector('#section_xo0bfknk_contents');
contractor_section.style.display = 'none';
//Секция локации
var location_section = document.querySelector('#section_h4fiawtu_contents');
location_section.style.display = 'none';
//Секция артисты
var artist_section = document.querySelector('#section_ptrkstfi_contents');
artist_section.style.display = 'none';
switch(curr_type_id){
case "CUSTOMER":
tota_section.style.display = 'table';
break;
case "SUPPLIER":
tota_section.style.display = 'table';
break;
case "COMPETITOR":
corporation_section.style.display = 'table';
break;
case "PARTNER":
partner_section.style.display = 'table';
break;
case "other":
supplier_section.style.display = 'table';
break;
case "1":
competitor_section.style.display = 'table';
break;
case "2":
smi_section.style.display = 'table';
break;
case "3":
contractor_section.style.display = 'table';
break;
case "4":
location_section.style.display = 'table';
break;
case "5":
artist_section.style.display = 'table';
break;
}
}
}
);