I have two text fields imageWidth and imageHeight... i want to take input from them, add current mouse poointer position and then do some stuff:
x = e.pageX - canvas.offsetLeft; y = e.pageY - canvas.offsetTop; var wWidth = document.getElementById('imageWidth').value; var wHeight = document.getElementById('imageHeight').value; var b = x + wWidth; alert(b); if(x+wWidth < 800 && y+wHeight < 1560) { //some work here } so if user enters 400 in width are and x returns 151... b's value will be 151400... whereas i want it to be 551 for the loop to work properly...
.valuereturns a string. See the linked duplicate for how to convert it to an integer