Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update and rename designs.js to designsJackR701.js #51

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions designs.js

This file was deleted.

40 changes: 40 additions & 0 deletions designsJackR701-2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Select color input
const tableColor = document.getElementById('inputColor');
// Select size input
const tableHeight = document.getElementById('inputHeight');
const tableWidth = document.getElementById('inputWidth');

// When size is submitted by the user, call makeGrid()
function makeGrid() {
var myTable = document.getElementById('pixelCanvas');
for (let i = 0; i < tableHeight.value; i++) {
const row = myTable.insertRow(0);
for (let j = 0; j < tableWidth.value; j++) {
const cell = row.insertCell(0);
cell.innerHTML = "";
cell.style.border = '1px solid gray';
cell.style.width = '40px';
cell.style.height = '40px';
}
}
}

// Your code goes here!
const form = document.getElementById('sizePicker');
form.addEventListener('submit', function(event) {
event.preventDefault();
makeGrid();
console.log("Making Grid, baby!");
});

function addColor(event) {
if (event.target.tagName === 'TD') {
var color = document.getElementById('colorPicker').value;
event.target.style.backgroundColor = color;
event.preventDefault();
}
}

const colorThis = document.getElementById('pixelCanvas');
colorThis.addEventListener('click', addColor);