how to change subfile column datatype from “input text” to checkbox in javascript

I have a subfile based on html table from third party application where I have to change a datatype from “Input text” to checkbox with default value ‘Y’ using javascript
I tried this:

let allInputElements = document.querySelectorAll('#jSubfile input[type=text]');
for (let i = 0; i<allInputElements.length; i++) {
allInputElements[i].type = 'checkbox';
allInputElements[i].value = 'Y';

}