javascript - Store JSignature output to mysql to be redrawn on separate page -
javascript - Store JSignature output to mysql to be redrawn on separate page -
can please explain me how take output of jsignature form , store in mysql database can stupid thing redraw on page later? swear sense such total idiot sometimes. please maintain in mind know little javascript , need walk me through step step.
ok so, have gotten jsignature working on page next code:
<div id="signatureparent"> <div id="signature"></div> <button type="button" onclick="$('#signature').jsignature('clear')">clear</button> <button type="button" onclick="alert($('#signature').jsignature('getdata','base30'))">save</button> </div> <div id="scrollgrabber"></div> <script src="jsig/src/jsignature.js"></script> <script src="jsig/src/plugins/jsignature.compressorbase30.js"></script> <script src="jsig/src/plugins/jsignature.compressorsvg.js"></script> <script src="jsig/src/plugins/jsignature.undobutton.js"></script> <script> $(document).ready(function() { var $sigdiv = $("#signature").jsignature({'undobutton':false}) }) </script>
this within form submitting bunch of info via $_post.
as can see, have added button display output alert window have no clue how place value within hidden input can submitted rest of form.
thank in advance.
funky plugin.
<div id="signatureparent"> <div id="signature"></div> <button type="button" onclick="$('#signature').jsignature('clear')">clear</button> <button type="button" id="btnsave">save</button> </div> <input type="hidden" id="hiddensigdata" name="hiddensigdata" /> <div id="scrollgrabber"></div> <script src="jsig/src/jsignature.js"></script> <script src="jsig/src/plugins/jsignature.compressorbase30.js"></script> <script src="jsig/src/plugins/jsignature.compressorsvg.js"></script> <script src="jsig/src/plugins/jsignature.undobutton.js"></script> <script> $(document).ready(function() { var $sigdiv = $("#signature").jsignature({'undobutton':false}); // -- explain here... $('#btnsave').click(function(){ var sigdata = $('#signature').jsignature('getdata','base30'); $('#hiddensigdata').val(sigdata); }); // -- ... here. }) </script>
that snippet of code above says: 1. "when button id 'btnsave' clicked"... 2. convert signature canvas bas64 encoded string, , save in variable called 'sigdata'. 3. set value of field id 'hiddensigdata' variable 'sigdata'.
boom, have it.
do have server-side code processing form? i've assumed you're using <form>
tags... field appear post'ed data.
if don't have handler data, you'll need c#/php depending on you're running. but, anyway.. that's js bit.
javascript php jquery mysql
Comments
Post a Comment