I have a client that would like to be able to draw on a form and have the drawing save automatically when submitting. Currently, when the user submits, the custom HTML is empty.
I am hoping that a checkbox can act as a trigger for JavaScript to convert the canvas to an image in another hidden field perhaps.
Anyone have any ideas?
Here is my JavaScript:
$(document).ready(function () {
$.getScript('https://intridea.github.io/sketch.js/lib/sketch.js', function() {
//script is loaded and executed put your dependent JS here
$.each(['#f00', '#ff0', '#0f0', '#0ff', '#00f', '#f0f', '#000', '#fff'], function() {
$('#colors_demo .tools').append("<a href='#colors_sketch' data-color='" + this + "' style='width: 10px; background: " + this + ";'></a> ");
});
$.each([3, 5, 10, 15], function() {
$('#colors_demo .tools').append("<a href='#colors_sketch' data-size='" + this + "' style='background: #ccc'>" + this + "</a> ");
});
//$('#colors_sketch').sketch();
$('#colors_sketch').sketch({defaultColor: "#000"});
});
});
Here is my CSS:
.tools { margin-bottom: 10px; }
.tools a {
border: 1px solid black;
height: 30px;
line-height: 30px;
padding: 0 10px;
vertical-align: middle;
text-align: center;
text-decoration: none;
display: inline-block;
color: black;
font-weight: bold;
}
And here is my Custom HTML Box:
<div class="demo" id="colors_demo">
<div class="tools">
<a href="#colors_sketch" data-tool="marker">Marker</a>
<a href="#colors_sketch" data-tool="eraser">Eraser</a>
<a href="#colors_sketch" data-download="png" style="float: right; width: 100px;">Download</a>
</div>
<canvas id="colors_sketch" width="750" height="500" style="border:2px solid #000000;"></canvas>
</div>