I am currently trying to capture information in a spreadsheet
with button onclick
but it has not been possible to generate the following error:
Uncaught ReferenceError: is not defined at HTMLButtonElement.onclick
Additionally, pressing this button requires me to go to a second page to continue capturing more information.
I did the information capture exercise with the function onsumbmit
and yes the capture is achieved but I did not achieve the step towards another page.
onbutton
Codigo.gs
function doGet() {
return HtmlService.createTemplateFromFile("Seleccion_Actividad").evaluate().setTitle("Iniciativas Operaciones");
}
function doPost(e){
Logger.Log(e);
}
function EnvioTipoActividad(info){
var sheet =SpreadsheetApp.openById('124cf1pMBO4dV2DgLxsPd3xa4XkZzEp4MhvA4xNnyXic').getActiveSheet();
sheet.appendRow([info.iniciativa]);
return 'Exitoso';
}
.Html file
<!DOCTYPE html>
<html>
<head>
<base target="_top">
</head>
<body>
<fieldset>
<legend>Seleccione Tipo de Actividad :</legend>
<label><input type="radio" name="actividad" value="01"required> Iniciativa </label><br>
<label><input type="radio" name="actividad" value="02"> Proyecto</label><br>
<label><input type="radio" name="actividad" value="03"> Requerimiento</label><br>
<label><input type="radio" name="actividad" value="04"> Idea</label><br><br>
<!--<input type="submit" value="Continuar"/>
<input type="reset" value="Limpiar"/>-->
<button onclick='EnvioTipoActividad(e)'>Continuar</button>
</fieldset>
<script>
function EnvioTipoActividad(e) {
e.preventDefault();
var info= {
iniciativa: e.target['actividad'].value,
}
google.script.run.withSuccessHandler(function(response) {
console.log(response);
}).EnvioTipoActividad(info);
}
</script>
</body>
</html>
2.Exercise with onsubmit
:
File Code.gs
function doGet() {
return HtmlService.createTemplateFromFile("Seleccion_Actividad").evaluate().setTitle("Iniciativas Operaciones");
}
function doPost(e){
Logger.Log(e);
}
function EnvioTipoActividad(info){
var sheet =SpreadsheetApp.openById('124cf1pMBO4dV2DgLxsPd3xa4XkZzEp4MhvA4xNnyXic').getActiveSheet();
sheet.appendRow([info.iniciativa]);
return 'Exitoso';
}
File.html
<!DOCTYPE html>
<html>
<head>
<base target="_top">
</head>
<body>
<form onsubmit="EnvioTipoActividad(event)">
<fieldset>
<legend>Seleccione Tipo de Actividad :</legend>
<label><input type="radio" name="actividad" value="01"required> Iniciativa </label><br>
<label><input type="radio" name="actividad" value="02"> Proyecto</label><br>
<label><input type="radio" name="actividad" value="03"> Requerimiento</label><br>
<label><input type="radio" name="actividad" value="04"> Idea</label><br><br>
<input type="submit" value="Continuar"/>
<input type="reset" value="Limpiar"/>
</fieldset>
</form>
<script>
function EnvioTipoActividad(e) {
e.preventDefault();
var info= {
iniciativa: e.target['actividad'].value,
}
google.script.run.withSuccessHandler(function(response) {
console.log(response);
}).EnvioTipoActividad(info);
}
</script>
</body>
</html>
HTML Element Selection
<!DOCTYPE html>
<html>
<head>
<base target="_top">
</head>
<body>
<form onsubmit="EnvioTipoElemento(event)">
<fieldset>
<legend>Seleccione Tipo de Elemento :</legend>
<input list="elemento" name="elemento">
<datalist id="elemento">
<option value="AM">
<option value="DARUMA">
<option value="UNOE">
<option value="SAP">
</datalist>
<input type="submit" value="Continuar">
<input type="reset" value="Limpiar">
</fieldset>
</form>
</body>
</html>