It shouldn't be this difficult to show a list of HTML inputs of check-boxes using javascript in a div that i want. what am i missing here.s my list and code.
var kitchen_work = [
" Wipe down baseboards",
" Wipe exterior of cabinets",
" polish stainless steel appliances",
" polish microwave interior",
" clean oven exterior",
" clean garbage disposal",
" clean sink fixtures/ drains",
" sink fixtures/drains",
" sweep-mop all floors",
" de-grease any appliances" ];
function show_kitchen() {
max = kitchen_work.length;
var x = [];
var t = [];
var div = document.createElement("div");
for (var i=0; i < max; i++) {
x[i] = document.createElement("input");
t[i] = document.createTextNode(kitchen_work[i])
x[i].setAttribute("type", "checkbox")
x[i].appendChild(t[i])
console.log(x[i]);
div.appendChild(x[i]);
}
document.getElementsByClassName("left-side").appendChild(div);
p = document.getElementsByClassName("left-side");
p.appendChild(div)
document.getElementsByClassName(left-side).appendChild(div);
}
<div class="middle-side">
<button type="button" id="kitchenroom" onclick="show_kitchen()"> kitchen </button>
</div>
The output I want is printing in the console but wont show inside my Div.
although I can use (document.body.appendChild(x))
and it inserts my check-boxes in the bottom of the page but I need it inside a div. I need to be able to replace it with another button of (ex: living room) and show another list.
I could have gone about it the wrong way. Any help's appreciated.