2017-07-25 00:33 阅读 96


I have a .php file that once a transaction is approved, I want it to show the signature pad but how will I implement it into my php code. The code below is a part of the .php file and I need to get this signature pad to show but it is in JavaScript.

 if($tran->result == "Approved"){



if($tran->result == "Approved"){

echo '<canvas id="signature-pad" class="signature-pad" width=400 
<button id="save">Save</button>

<button id="clear">Clear</button>

 <script type="javascript" src=""></script> <script> var signaturePad = new 
 SignaturePad(document.getElementById('signature-pad'), {
  backgroundColor: 'rgba(255, 255, 255, 0)',
  penColor: 'rgb(0, 0, 0)'
var saveButton = document.getElementById('save');
var cancelButton = document.getElementById('clear');

saveButton.addEventListener('click', function (event) {
  var data = signaturePad.toDataURL('image/png');

// Send data to server instead...;

cancelButton.addEventListener('click', function (event) {
});    </script> </script><script src="touchpadjs.js"></script>
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

2条回答 默认 最新

  • 已采纳
    douzhanshen0657 douzhanshen0657 2017-07-26 03:05

    Found out what was wrong, the js file was not being accessed by the html and css code so i just added all the code into the php function as with for javascript and for css and it all started working.

    点赞 评论 复制链接分享
  • doutucui0133 doutucui0133 2017-07-25 00:37

    you output the HTML code snippet echo '<canvas id="signature-pad" class="signature-pad" width=400 height=200></canvas>' once approved. You can include JS files in your webpage already or you can include it under above code as <script type="javascript" src=""></script> followed by your own JS code <script src="Path_to_your_own_JS_file"></script>

    Example code is already present on the same link at the bottom:

    点赞 评论 复制链接分享