Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在URL Google apps脚本和更新字段上传递参数_Javascript_Url_Google Apps Script_Google Sheets_Web Applications - Fatal编程技术网

Javascript 在URL Google apps脚本和更新字段上传递参数

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

我有一个带有应用程序脚本和引导4的HTML表单。在这种形式下,我有一个输入字段和它的值,它来自URL上的参数。当我将参数传递给字段时,我必须更新第二个字段。但是当我发送带有参数的url时,第二个字段不会更新

这是我的代码:

<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修改
    estado
    的文本框,该URL包括
    https://script.google.com/macros/s/###/exec?inputid=###
修改点:
  • 在本例中,如何修改
    google.script.url.getLocation
修改脚本:
  • 这样,当您使用
    https://script.google.com/macros/s/###/exec?inputid=###
    ,通过执行
    getId()
    函数修改
    estado
    文本框的值
参考:

请阅读,然后添加(添加服务器端(.gs)和客户端(.html)代码)我成功地将参数传递给inputid,但第二个字段(estado)没有更新。输入字段estado由inputid上的值决定。当我更改inputid的值时,我的脚本将转到一个DB,并像从excel获取vlookup一样获取estado的值。然后,当我更改inputid时,我的代码将在数据库的列estado上搜索或查找值。当我在URL中传递参数时,字段estado不会更新。。。抱歉,如果我的语法不太好,我在Code.GS上更改了一个值,现在正在工作!!但是有你的帮助和支持…非常感谢你,塔奈克!
google.script.url.getLocation(function(location) {
  document.getElementById("inputid").value = location.parameters.inputid[0];
  getId();  // Added
});