我正在尝试为我的数字签名添加重置按钮,如果我签名并需要更改我的签名,我需要能够将图像重置为空白并再次开始签名,您能解释一下如何操作吗?谢谢你。
<div class="m-signature-pad">
<div class="m-signature-pad--body">
<img style="width: 260px; height: 60px; margin:0px; padding: 0px; filter:sepia()(100%);" id="imagefetch1">
</div>
</div>
<script>
function init() {
var docDescription = 'Please sign below';
var reqUrl = 'http://localhost:12001/SigCaptureWait?ResponseType=API&UseReceiptDataList=1&ReturnSigType=PNG&CreateFile=false&TopazType=1';
docDescription = docDescription.replaceAll(' ', '%20');
reqUrl += '&ReceiptData=' + docDescription;
fetch(reqUrl)
.then(data => data.json())
.then(data => {
if (data.successful) {
$("#imagefetch1").attr("src","data:image/png;base64," + data.response.PNG);
}
})
.catch(e => {
console.log('Error fetching image', e)
})
}
</script>
<div class="form-row" >
<label for="signature" type="label"><strong>Signature</strong></label>
<input style="margin-left:90px; margin-top: 10px; border:transparent; width: 150px;" type="date" name="date" >
<button style="position:relative; top:-40px;" type="button" value="clear" id="clear">Reset</button>
<button style="position:relative;right:90px;top:-80px; line-height: 17px;" type="button" value="clear" id="clickto" onclick="init()">Click to Sign</button>
</div>
解决了我的问题,我是 JS 新手,它可能不是最有用的代码,但它确实符合我的目的,如果你能提出更好的方法,我很感激。谢谢你。
<script>
function init() {
var docDescription = 'Please sign below';
var reqUrl = 'http://localhost:12001/SigCaptureWait?ResponseType=API&UseReceiptDataList=1&ReturnSigType=PNG&CreateFile=false&TopazType=1';
docDescription = docDescription.replaceAll(' ', '%20');
reqUrl += '&ReceiptData=' + docDescription;
fetch(reqUrl)
.then(data => data.json())
.then(data => {
if (data.successful) {
$("#imagefetch1").attr("src","data:image/png;base64," + data.response.PNG);
}
$('#imagefetch1').show();
})
.catch(e => {
console.log('Error fetching image', e)
})
}
function clear() {
$('#imagefetch1').hide();
}
</script>