douyi9787
2017-07-25 00:33
浏览 105
已采纳

在.php文件中添加javascript签名板

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 https://github.com/szimek/signature_pad this signature pad to show but it is in JavaScript.

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

}

d

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



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

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

?>
 <script type="javascript" src="https://cdnjs.cloudflare.com/ajax/libs/signature_pad/1.5.3/signature_pad.min.js"></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...
  window.open(data);
});

cancelButton.addEventListener('click', function (event) {
  signaturePad.clear();
});    </script> </script><script src="touchpadjs.js"></script>

图片转代码服务由CSDN问答提供 功能建议

我有一个.php文件,一旦交易被批准,我希望它显示签名板,但是如何 我将它实现到我的PHP代码中。 下面的代码是.php文件的一部分,我需要 https://github.com/szimek/ signature_pad 此签名板显示但它是在JavaScript中。

  if($ tran-&gt; result ==“Approved”){
 
} 
   
 
 

d

  if($ tran-&gt; result ==“Approved”){
?&gt; 
 
 
 
&lt;?
echo'&lt;  ; canvas id =“signature-pad”class =“signature-pad”width = 400 
height = 200&gt;&lt; / canvas&gt; 
&lt; div&gt; 
&lt; button id =“save”&gt;保存&lt; / button&gt  ; 
 
&lt; button id =“clear”&gt;清除&lt; / button&gt; 
&lt; / div&gt;'
 
?&gt; 
&lt; script type =“javascript”src =“https://  cdnjs.cloudflare.com/ajax/libs/signature_pad/1.5.3/signature_pad.min.js"></script>  &LT;脚本&GT;  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'); 
 
 //将数据发送到服务器... 
 window.open(data); 
}); 
 
cancelButton.addEventListener(' 点击',function(event){
 signaturePad.clear(); 
});  &LT; /脚本&GT;  &lt; / script&gt;&lt; script src =“touchpadjs.js”&gt;&lt; / script&gt; 
   
 
 

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • 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.

    评论
    解决 无用
    打赏 举报
查看更多回答(1条)

相关推荐 更多相似问题