Javascript 在URL Google apps脚本和更新字段上传递参数
我有一个带有应用程序脚本和引导4的HTML表单。在这种形式下,我有一个输入字段和它的值,它来自URL上的参数。当我将参数传递给字段时,我必须更新第二个字段。但是当我发送带有参数的url时,第二个字段不会更新 这是我的代码:Javascript 在URL Google apps脚本和更新字段上传递参数,javascript,url,google-apps-script,google-sheets,web-applications,Javascript,Url,Google Apps Script,Google Sheets,Web Applications,我有一个带有应用程序脚本和引导4的HTML表单。在这种形式下,我有一个输入字段和它的值,它来自URL上的参数。当我将参数传递给字段时,我必须更新第二个字段。但是当我发送带有参数的url时,第二个字段不会更新 这是我的代码: <div class="form-row"> <div class="form-group col-md-6"> <label for="inputid">Identificado
<div class="form-row">
<div class="form-group col-md-6">
<label for="inputid">Identificador de viaje</label>
<input type="text" class="form-control" id="inputid" required>
<div class="invalid-feedback">
No ha ingresado los datos o el viaje señalado ya se encuentra cerrado.
</div>
</div>
<div class="form-group col-md-6">
<label for="estado">Estado</label>
<input type="text" class="form-control" id="estado" required disabled>
<div class="invalid-feedback">
No ha ingresado los datos o estos no son válidos.
</div>
</div>
</div>
<script>
var arrayOfValues;
function afterButtonClicked(){
if(validate()){
var cuenta = document.getElementById("cuenta");
var inputid = document.getElementById("inputid");
var estado = document.getElementById("estado");
var kmfinal = document.getElementById("kmfinal");
var rowDataarrive = {cuenta: cuenta.value,inputid:inputid.value,
estado: estado.value,kmfinal:kmfinal.value,
};
google.script.run.addNewRowarrive(rowDataarrive);
$('#modal').modal('hide')
$('#successnotification').toast('show')
setTimeout(function(){location.reload()}, 6000);
} else{
$('#modal').modal('hide')
$('#errornotification').toast('show')
}
}
function validate(){
var fieldsToValidate = document.querySelectorAll("#userform input, #userform select");
Array.prototype.forEach.call(fieldsToValidate, function(el){
if(el.checkValidity()){
el.classList.remove("is-invalid");
}else{
el.classList.add("is-invalid");
}
});
return Array.prototype.every.call(fieldsToValidate, function(el){
return el.checkValidity();
});
}
function getId(){
var idCode = document.getElementById("inputid").value;
google.script.run.withSuccessHandler(updateIdcode).getId(idCode);
}
function updateIdcode(estadolist){
document.getElementById("estado").value = estadolist;
}
google.script.url.getLocation(function(location) {
document.getElementById("inputid").value = location.parameters.inputid[0];
});
document.getElementById("inputid").addEventListener("input",getId);
document.getElementById("enviar").addEventListener("click",afterButtonClicked);
document.getElementById("loading").remove();
</script>
维亚杰酒店
没有任何人会在塞尔拉多附近的艾尔维亚耶大道上看到达托斯。
埃斯塔多
没有安格拉多·洛斯·达托斯和埃斯托斯,没有儿子瓦利多。
var阵列价值;
函数afterButtonClicked(){
if(validate()){
var cuenta=document.getElementById(“cuenta”);
var inputid=document.getElementById(“inputid”);
var estado=document.getElementById(“estado”);
var kmfinal=document.getElementById(“kmfinal”);
var rowDataArrival={cuenta:cuenta.value,inputid:inputid.value,
estado:estado.value,kmfinal:kmfinal.value,
};
google.script.run.addNewRowArrival(RowDataArrival);
$('#model')。model('hide'))
$('successnotification')。toast('show')
setTimeout(函数(){location.reload()},6000);
}否则{
$('#model')。model('hide'))
$('#errornotification').toast('show'))
}
}
函数验证(){
var fieldsToValidate=document.queryselectoral(#用户表单输入,#用户表单选择”);
Array.prototype.forEach.call(fieldsToValidate,function(el){
if(el.checkValidity()){
el.classList.remove(“无效”);
}否则{
el.classList.add(“无效”);
}
});
返回Array.prototype.every.call(fieldsToValidate,function(el){
返回el.checkValidity();
});
}
函数getId(){
var idCode=document.getElementById(“inputid”).value;
google.script.run.withSuccessHandler(updateIdcode).getId(idCode);
}
函数updateIdcode(estadolist){
document.getElementById(“estado”).value=estadList;
}
google.script.url.getLocation(函数(位置){
document.getElementById(“inputid”).value=location.parameters.inputid[0];
});
document.getElementById(“inputid”).addEventListener(“input”,getId);
document.getElementById(“enviar”).addEventListener(“单击”,点击后按钮);
document.getElementById(“加载”).remove();
然后,当我在导航器上发送带有参数的url时,输入字段“estado”不会更新
我的问题是什么?我相信你的目标如下
- 您想通过访问URL修改
的文本框,该URL包括estado
https://script.google.com/macros/s/###/exec?inputid=###
- 在本例中,如何修改
google.script.url.getLocation
- 这样,当您使用
,通过执行https://script.google.com/macros/s/###/exec?inputid=###
函数修改getId()
文本框的值estado
google.script.url.getLocation(function(location) {
document.getElementById("inputid").value = location.parameters.inputid[0];
getId(); // Added
});