Reputation: 317
I am using jQuery UI Signature (http://keith-wood.name/signature.html) inside a form to capture a signature. This is working fine. I am trying to find out how to pass that data to my action page via the form. Here is what I have been working with:
<script src="scripts/jquery.signature.js"></script>
<script>
$(function() {
var sig = $('#sig').signature();
$('#disable').click(function() {
var disable = $(this).text() === 'Disable';
$(this).text(disable ? 'Enable' : 'Disable');
sig.signature(disable ? 'disable' : 'enable');
});
$('#clear').click(function() {
sig.signature('clear');
});
$('#json').click(function() {
alert(sig.signature('toJSON'));
});
$('#svg').click(function() {
alert(sig.signature('toSVG'));
});
$('#sig').signature({guideline: true});
});
</script>
<div id="sig"></div>
<p style="clear: both;">
<button type="button" id="disable">Disable</button>
<button type="reset" id="clear">Clear</button>
<button type="button" id="json">To JSON</button>
<button type="button" id="svg">To SVG</button>
</p>
<input type="hidden" value="signature" name="sig_form">
Upvotes: 0
Views: 911
Reputation: 15857
If you have no plans on using AJAX, the simplest method is to create a hidden field for storing the jSON and set its value to the jSON.
<input type="hidden" name="signature" class="signature" value="">
$('form').submit(function() {
$(".signature").val(sig.signature('toJSON'));
});
modified based on @moob's comment
Upvotes: 2