Simply quantize the x and y values you get from mouse position on click:
build_canvas.onclick = function(e) {
var rect = build_canvas.getBoundingClientRect(), // canvas abs. position
x = e.clientX - rect.left, // relative x to canvas
y = e.clientY - rect.top; // relative y to canvas
x = ((x / 15)|0) * 15; // quantize x by 15
y = ((y / 10)|0) * 10; // quantize y by 10
build_context.fillRect(x+1, y+1, 14, 9); // fill rectangle
}
This quantizing does:
(x / 15)|0
divide by 15 and remove fraction. Then multiply it up again by the same number to get the start position of the cell:
((x / 15)|0) * 15
and the same for y
.