JS to detect the checked checkboxes in addNewMaterial. Can be used in other classes