I’m trying to call a function from a library in a HTML page but it doesn’t work :
<!DOCTYPE html>
<html>
<head>
<base target="_top">
</head>
<body>
<form id="myForm">
<label for="champ1">Champ 1 :</label>
<input type="text" name="champ1" id="champ1" required><br>
<label for="champ2">Champ 2 :</label>
<input type="text" name="champ2" id="champ2" required><br>
<input type="submit" value="Valider">
</form>
<script>
var DATABASE_POST_TREATMENT_ID = '1HGHZ2xWdeN02vNOQ-XZyaoDMNxkIrz8ck5Psl5W3pdg';
document.getElementById("myForm").addEventListener("submit", function(e) {
e.preventDefault();
// Récupérez les valeurs des champs champ1 et champ2
var champ1 = document.getElementById("champ1").value;
var champ2 = document.getElementById("champ2").value;
// Exécutez votre fonction baseFinale avec les valeurs
google.script.run.DatabaseposttreatmentMaster.coconexion(DATABASE_POST_TREATMENT_ID,champ1,champ2);
google.script.host.closeDialog();
// Réinitialisez le formulaire
document.getElementById("myForm").reset();
});
</script>
</body>
</html>
I’ve got the following message in the console :
Uncaught TypeError: Cannot read properties of undefined (reading 'coconexion')
at HTMLFormElement.<anonymous>
How can i solve the problem ?
2
Answers
Try calling it by name through an intermediate function like this:
Handling Arguments:
Copy the following functions, paste and save and run testFunk the execution log is show below.
If your executing a library call then change
this
to the library nameRead the library documentation that you’re trying to implement, there must be an installation page, normally it’s from
npm install
if your project is using Node.js or maybe there is a CDNhttps://cdnjs...
make sure to added in your HTML script taghope it helps!