I am a newbie. I am trying to make a pixel art maker. I cannot figure out where I am going wrong at. It lets me choose the size and pick the color but when I hit enter to make the grid, it doesn't do anything. It just goes back to the original settings with 1 filled in and the color black. Any help would be appreciated.
let colorPicker = document.getElementById("colorPicker").value;
let height = document.getElementById("inputHeight").value;
let width = document.getElementById("inputWidth").value;
let table = document.getElementById("pixelCanvas");
let sizePicker = document.getElementById("sizePicker");
sizePicker.addEventListener('sumbit', function(event) {
event.preventDefault()
let height = document.getElementById("inputHeight").value;
let width = document.getElementById("inputWidth").value;
makeGrid(height, width);
});
function makeGrid(height, width); {
let height = document.getElementById("inputHeight");
let width = document.getElementById("inputWidth");
table.innerHTML = null;
for (let i = 0; i < height; i++) {
let row = table.insertRow(i);
for (let j = 0; j < width; j++) {
let cell = row.insertCell(j);
cell.addEventListener("click", function(event) {
cell.style.backgroundColor = colorPicker.value;
});
cell.addEventListener("dblclick", function(event) {
cell.style.backgroundColor = "";
});
}
}
}
body {
text-align: center;
}
h1 {
font-family: Monoton;
font-size: 70px;
margin: 0.2em;
}
h2 {
margin: 1em 0 0.25em;
}
h2:first-of-type {
margin-top: 0.5em;
}
table,
tr,
td {
border: 1px solid black;
}
table {
border-collapse: collapse;
margin: 0 auto;
}
tr {
height: 20px;
}
td {
width: 20px;
}
input[type=number] {
width: 6em;
}
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Monoton">
<h1>Pixel Art Maker</h1>
<h2>Choose Grid Size</h2>
<form id="sizePicker">
Grid Height:
<input type="number" id="inputHeight" name="height" min="1" value="1"> Grid Width:
<input type="number" id="inputWidth" name="width" min="1" value="1">
<input type="submit">
</form>
<h2>Pick A Color</h2>
<input type="color" id="colorPicker">
<h2>Design Canvas</h2>
<table id="pixelCanvas"></table>