Js generates input, and cannot display text.

The

js function generates a multi-checkbox group, but the text is not displayed.
< div id= "product-radio-wrapper" > < / div >
< script >
createCheckbox (document.getElementById ("product-radio-wrapper"), [" Mobile", "Notebook", "Smart Speaker"], "product");
function createCheckbox (id,arr,name) {

var len = arr.length,
    i,
    label;
for (i = 0 ;i < len;iPP) {
    var cbox = document.createElement("input"),
        label = document.createElement("label");
    cbox.type = "checkbox";
    cbox.value = arr[i];
    cbox.name = name;
    cbox.innerHTML = arr[i];
    label.appendChild(cbox);
    id.appendChild(label);
}

}
< / script >
is shown as follows:

clipboard.png

Mar.23,2021
The value attribute value of the

check box is not displayed in the user interface. You have to create another tag to show the user


.

dynamic insert checkbox test

createCheckbox(document.getElementById('product-radio-wrapper'),['','',''],'product');
    function createCheckbox(id,arr,name) {
        var len = arr.length,
            i,
            label;
        for (i = 0 ;i < len;iPP) {
            var div = document.createElement('div');
            var cbox = document.createElement('input');
            var label = document.createElement('label');
            label.innerText = arr[i];
            cbox.type = 'checkbox';
            cbox.value = arr[i];
            cbox.name = name;
            cbox.innerHTML = arr[i];
            div.appendChild(label);
            div.appendChild(cbox);
            id.appendChild(div);
        }
    }

clipboard.png

change cbox to label

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b304ee-2b068.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b304ee-2b068.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?