Wie sende ich ein Formular in diesem Code mit HTML und GS? Es wird nicht gesendet, wenn ich auf "Senden" klicke. Ich denke, es gibt einen Fehler mit der 'send()' Funktion, oder vielleicht hat das Formular Fehler. Bitte hinterlassen Sie eine Antwort. Danke im Voraus!Senden von Formularen mit HTML und Google Apps Script
HTML:
<!DOCTYPE html>
<!-- Quiz By Yona Klatchko -->
<html>
<head>
<base target="_top">
</head>
<body>
<p class="BoldVerdana">
Welcome to Yona's Geography Quiz.
</p>
<p class="BoldVerdana">
Begin whenever you are ready.
</p>
<br/>
<script>
function send() {
var emailAddress = document.getElementById('emailAddress').value;
var result = document.getElementById('Questions').value;
google.script.run.send(emailAddress, result);
}
</script>
<style>
p.BoldVerdana {
font-weight: bold;
font-family: "Verdana";
}
</style>
<br/>
<font face="Verdana">
Your teacher's email address
</font>
<br/>
<br/>
<input type="name" id="emailAddress"/>
<br/>
<br/>
<div id="answers">
<form name="Questions" id="Questions" method="post" action="EmailAddress; subject=Geography Quiz Answers enctype='text/plain'">
<p class="BoldVerdana">
Input questions
</p>
<font face="Verdana">
1. Which state has a climate suitable for growing citrus fruits — California or Maine?
</font>
<br/>
<br/>
<input type="text" id="Ia1">
<br/>
<br/>
<br/>
<font face="Verdana">
2. The North Atlantic current brings warm waters from the tropics to the west coast of which continent?
</font>
<br/>
<br/>
<input type="text" id="Ia2">
<br/>
<br/>
<br/>
<font face="Verdana">
3. Which Canadian province produces more than half of the country's manufactured goods?
</font>
<br/>
<br/>
<input type="text" id="Ia3">
<br/>
<br/>
<br/>
<font face="Verdana">
4. To visit the ruins of Persepolis, an ancient ceremonial capital of Persia, you would have to travel to what present-day country?
</font>
<br/>
<br/>
<input type="text" id="Ia4">
<br/>
<br/>
<br/>
<font face="Verdana">
5. What is the term for a part of an ocean or sea that cuts far into the bordering landmass and may contain one or more bays?
</font>
<br/>
<br/>
<input type="text" id="Ia5">
<br/>
<br/>
<br/>
<p class="BoldVerdana">
Multiple choice
</p>
<font face="Verdana" id="Ma1">
6. Which one of the following zones of the atmosphere is rich in Ozone gas?
<br/>
<input type="radio" name="6. Which one of the following zones of the atmosphere is rich in Ozone gas?" value="Mesosphere">
Mesosphere
<br/>
<input type="radio" name="6. Which one of the following zones of the atmosphere is rich in Ozone gas?" value="Troposphere">
Troposphere
<br/>
<input type="radio" name="6. Which one of the following zones of the atmosphere is rich in Ozone gas?" value="Ionosphere">
Ionosphere
<br/>
<input type="radio" name="6. Which one of the following zones of the atmosphere is rich in Ozone gas?" value="Stratosphere">
Heat is generated in it
\t \t <br/>
\t \t <br/>
\t \t </font>
<font face="Verdana" id="Ma2">
7. Troposphere is the hottest part of the atmosphere because
<br/>
<input type="radio" name="7. Troposphere is the hottest part of the atmosphere because" value="It is closest to the sun">
It is closest to the sun
<br/>
<input type="radio" name="7. Troposphere is the hottest part of the atmosphere because" value="It is heated by the Earth's surface">
It is heated by the Earth's surface
<br/>
<input type="radio" name="7. Troposphere is the hottest part of the atmosphere because" value="There are charged particles in it">
There are charged particles in it
<br/>
<input type="radio" name="7. Troposphere is the hottest part of the atmosphere because" value="Heat is generated in it">
Heat is generated in it
\t \t <br/>
\t \t <br/>
</font>
<font face="Verdana" id="Ma3">
8. Continents have drifted apart because of
<br/>
<input type="radio" name="8. Continents have drifted apart because of" value="Volcanic eruption">
Volcanic eruption
<br/>
<input type="radio" name="8. Continents have drifted apart because of" value="Folding and Faulting of rocks">
Folding and Faulting of rocks
<br/>
<input type="radio" name="8. Continents have drifted apart because of" value="Tectonic activities">
Tectonic activities
<br/>
<input type="radio" name="8. Continents have drifted apart because of" value="All of the above">
All of the above
<br/>
</font>
<br/>
</form>
</div>
<button onclick="send(); Submit" value="Submit">
<font face="Verdana" size="10">
Submit
</font>
</button>
</body>
</html>
GS:
Send():
function send(emailAddress, result) {
MailApp.sendEmail(emailAddress, result)
}
doGet:
function doGet() {
return(HtmlService.createTemplateFromFile('Quiz.html').evaluate().setTitle('Geo Quiz').setSandboxMode(HtmlService.SandboxMode.IFRAME));
}
Nun verwenden zunächst die Entwicklertools Ihres Browsers um den Code zu überprüfen und sehen, welche Fehler Pop-up in der Konsole. Nicht sicher, warum Ihr On-Click-Attribut "send(); Submit" ist, sollte wahrscheinlich den Submit-Teil entfernen – Gerneio