var texte = document.getElementById("texto_lineas");
var boton = document.getElementById("botoncito");
boton.addEventListener("click", dibujoPorClick );
var d = document.getElementById("dibujito");
var lienzo = d.getContext("2d");
var lineas = 30;
var l = 0;
var yi, xf;
for(l = 0; l < lineas; l++)
{
yi = 10 * l;
xf = 10 * (l + 1)
dibujarLinea("red", 0, yi, xf, 300);
console.log("linea " + l);
}
dibujarLinea("red", 1,1,1,299)
dibujarLinea("red", 1,299,299,299)
function dibujarLinea(color, xinicial, yinicial, xfinal, yfinal)
{
lienzo.beginPath();
lienzo.strokeStyle = color;
lienzo.moveTo(xinicial, yinicial);
lienzo.lineTo(xfinal, yfinal);
lienzo.stroke();
lienzo.closePath();
}
function dibujoPorClick()
{
var p = texto.value;
alert("no me toques " + p);
}
I do not recognize the variable p
containing texto.value
. What do I do?