Ok, you are close, some corrections:
- Instead of loading the external emailjs library like that, use the PlayCanvas external scripts tab in your project settings. That will ensure the library is loaded as soon as the app starts:

- I reworked your HTML a bit to add an ID to the form element. That is used later on to attach an event handler:
<div class="container">
<form id="contact-form">
<label for="osis">OSIS Number</label>
<input type="number" id="osis" name="osis" placeholder="Your OSIS number..">
<br/>
<label for="email">Email</label>
<input type="email" id="email" name="email" placeholder="Your Email address..">
<br/>
<label for="feedback">Feedback</label>
<textarea id="feedback" name="feedback" placeholder="Your feedback on the gaming assessment.." style="height:200px"></textarea>
<br/>
<input type="submit" value="Submit">
</form>
</div>
- Lastly, here is the updated Game.js code that seems to be working now. I added an
event.preventDefault()
call on submit, otherwise the page will reload.
//call email.js library
emailjs.init("YOUR EMAILJS ID");
document.getElementById('contact-form').addEventListener('submit', function (event) {
event.preventDefault();
let params = {
osis: document.getElementById("osis").value,
email: document.getElementById("email").value,
feedback: document.getElementById("feedback").value,
score: this.score
};
const serviceID = "serviceID ";
const templateID = "templateID";
emailjs
.send(serviceID, templateID, params)
.then((res) => {
document.getElementById("osis").value = "";
document.getElementById("email").value = "";
document.getElementById("feedback").value = "";
alert("your email sent successfully");
}
)
.catch((err) => consolde.log(err));
});
EDIT: I removed your emailjs IDs from my reply.