【问题标题】:How to open camera to scan QR code into Google Form field?如何打开相机将二维码扫描到 Google 表单字段中?
【发布时间】:2020-08-05 19:42:13
【问题描述】:
我们使用 Google 表单来跟踪某些事件的进入情况。工作人员和与会者输入他们的 ID 号码,该号码与 QR 码一起分发。
我的任务是试图弄清楚我们如何访问 iPad 摄像头(我们使用 iPad 制作表格)以扫描与会者的二维码,并将他们的 ID 号从输入到表格中正确字段的代码中获取。
我相信我们可以以某种方式使用 Google Apps 脚本,但我不确定。
【问题讨论】:
标签:
google-apps-script
camera
qr-code
google-forms
【解决方案1】:
最近对用于 webapps 的 iphone 对话框的更改使我可以访问一个对话框,该对话框允许我选择文件上传的来源,其中一个选项是相机。我上传了一张显示对话框的应用程序图像。我还包含了我的 html,以便您可以看到它只是一个文件上传。也许这会有所帮助。
带对话框的应用图片:
这是我的html:
<!DOCTYPE html>
<html>
<head>
<base target="_top">
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script>
$(function(){
google.script.run
.withSuccessHandler(function(rObj){
$('#dt').val(rObj.date);
})
.initForm();
});
function fileUploadJs(frmData) {
var amt=$('#amt').val();
var vndr=$('#vndr').val();
var img=$('#img').val();
if(!amt){
window.alert('No amount provided');
$('#amt').focus();
return;
}
if(!vndr) {
window.alert('No vendor provided');
$('#vndr').focus();
return;
}
if(!img) {
window.alert('No image chosen');
$('#img').focus();
}
document.getElementById('status').style.display ='inline';
google.script.run
.withSuccessHandler(function(hl){
document.getElementById('status').innerHTML=hl;
})
.uploadTheForm(frmData)
}
console.log('My Code');
</script>
<style>
input,textarea{margin:5px 5px 5px 0;}
</style>
</head>
<body>
<h3 id="main-heading">Receipt Information</h3>
<div id="formDiv">
<form id="myForm">
<br /><input type="date" name="date" id="dt"/>
<br /><input type="number" name="amount" placeholder="Amount" id="amt" />
<br /><input type="text" name="vendor" placeholder="Vendor" id="vndr"/>
<br /><textarea name="notes" cols="40" rows="2" placeholder="NOTES"></textarea>
<br/>Receipt Image
<br /><input type="file" name="receipt" id="img" />
<br /><input type="button" value="Submit" onclick="fileUploadJs(this.parentNode)" />
</form>
</div>
<div id="status" style="display: none">
<!-- div will be filled with innerHTML after form submission. -->
Uploading. Please wait...
</div>
</body>
</html>