我有一个 .php 文件,一旦交易被批准,我希望它显示签名板,但我将如何将它实现到我的 php 代码中。下面的代码是 .php 文件的一部分,我需要获取https://github.com/szimek/signature_pad这个签名板才能显示,但它是在 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>