Advertisement
Guest User

Untitled

a guest
Jan 5th, 2023
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const flagCanvas = document.getElementById('flag-canvas');
  2.  
  3. const stripeAmountInput = document.getElementById('stripe-amount-input');
  4. let ctx = flagCanvas.getContext("2d");
  5.  
  6. const colorInputContainer = document.getElementById('color-input-container');
  7.  
  8. let stripeAmount = [];
  9.  
  10. ctx.fillStyle = "#FF0000";
  11. ctx.fillRect(0, 0, 150, 75);
  12.  
  13. stripeAmountInput.addEventListener('change', (event) => {
  14.     while (colorInputContainer.firstChild) {
  15.         console.log(1);
  16.         console.log(colorInputContainer);
  17.         console.log(colorInputContainer.firstChild)
  18.         colorInputContainer.removeChild(colorInputContainer.firstChild);
  19.     }
  20.  
  21.     if(stripeAmountInput.value < 0){
  22.         stripeAmountInput.value = 0;
  23.     }
  24.  
  25.     for(i = 0; i < stripeAmountInput.value; i++){
  26.         stripeAmount.push(i);
  27.     }
  28.    
  29.     stripeAmount.forEach(element => {
  30.         let colorPickerInput = document.createElement('input');
  31.         colorPickerInput.setAttribute('type', 'color');
  32.         colorInputContainer.appendChild(colorPickerInput);
  33.     });
  34. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement