I'm trying to do a form with JavaScript where, after adding the required information and clicking the submit button, the users email account is opened with the information already laid out, so that they just have to send it. I haven't been able to get it to work since it includes multiple ids. Here's my code
function sendMail() {
var link
= "mailto: example@gmail.com"
+ "?cc=mycc@gmail.com"
+ "&subject="
+ encodeURIComponent("Ficha")
+ "&body="
+ encodeURIComponent (
document.querySelectorAll("#dead1, #dead2").value
);
window.location.href = link;
}
at first I tried using getElementById, but I was only able to get one of them and I have a total of 6. I think it might have something to do with the way the form is made, so here's a piece of the code from the form
<div class="row">
<div class="col-25">
<label for="dead4">Edad y cumpleaños;</label>
</div>
<div class="col-75">
<input type="text" id="dead4" name="edad"
placeholder="Mayores de 18 años." minlength="2" required />
</div>
</div>
this format repeats a few times, each with different ids. This format does open an email, but the body only says "undefined"