JSFiddle - React, Tailwind, and code Playground
HTML
<textarea> your message </textarea>
<input type="text" placeholder="name" name="name" />
<input type="text" placeholder="lastname" name="lastname" />
<label>
<input type="radio" name="rboption" value="yes" /> YES
</label>
<label>
<input type="radio" name="rboption" value="no" />NO
</label>
<br>
<a href="mailto:[email protected]" style="display:inline-block; background:#333; color:#FFF; padding:5px 10px 5px 10px; margin:15px 0 0 0; text-decoration:none" class="submit">Sent the email</a>
JavaScript
function sendEmail(){
var answerArr = [];
$("input, textarea").each(function(){
if($(this).attr("type") === "radio"){
if($(this).is(":checked")){
answerArr.push($(this).val());
}
}else{
answerArr.push($(this).val());
}
});
var body = answerArr.join("\n");
var mailto = "[email protected]";
var a = document.createElement('a');
a.href = "mailto:" + mailto + "?body=" + escape(body);
console.log(a.href);
a.click();
}
$(document).on("click",".submit",sendEmail);