Advertisement
Guest User

Untitled

a guest
Feb 27th, 2020
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. // Select color input
  2. const colorPicker = document.getElementById('colorPicker');
  3.  
  4. // Select size input
  5. const sizePicker = document.getElementById('sizePicker');
  6.  
  7. // When size is submitted by the user, call makeGrid()
  8. document.querySelector('input[type="submit"]').addEventListener('click', SubmitButton);
  9. function SubmitButton(event){
  10. event.preventDefault();
  11. makeGrid();
  12. }
  13. function makeGrid() {
  14. const grid = document.getElementById('pixelCanvas');
  15. var height = document.getElementById('inputHeight').value;
  16. var width = document.getElementById('inputWidth').value;
  17. // Create Grid
  18. grid.innerHTML=null; //resets the grid
  19. for (var v = 0; v < height; v++){
  20. var row = document.createElement('tr')
  21. row.id = 'row-' + v;// not sure I understand perfectly this
  22. grid.appendChild(row);
  23. for(var h = 0; h < width; h++){
  24. var col = document.createElement('td')
  25. col.id = 'row-' + row + '-' + h;
  26. grid.lastChild.appendChild(col);
  27. }
  28. }
  29. }
  30. //Trouble puting the colors in the squares and not sure how to create a code to put back a blanlk square if error
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement