lundi 20 avril 2020

How do I make the subject not be the message when using mailto: in html and javascript?

I'm trying to add a contact me page to the website I am coding for myself. It's nothing much, basically just a couple text boxes that take the person's email, subject, and message, and then open a mailto: link. For some reason though, he subject is showing up as whatever the message is. How can I fix this?

If it turns out what I'm doing is just a waste of time, any ideas for a better way are appreciated to :)

HTML

<tr>
            <td><bsh>Your Email Address: </bsh> </td>
            <td><td style="width: 1px;"><div class="trd"><input class="emailInputs" type="text" id="userEmail"></div><td style="width: 1px;"></td>
        </tr><tr>
            <td><bsh>Subject: </bsh> </td>
            <td><td style="width: 1px;"><div class="trd"><input class="emailInputs" type="text" id="subject"></div><td style="width: 1px;"></td>
        </tr><tr>
        <td><bsh>Message: </bsh> </td></tr></table>
        <table style="padding-left: 0;">
            <tr><td><textarea class="emailMessage" id="message">Enter your message here</textarea></td><td style="width: 1px;"></td></tr>
        </table>
        <div class="mailcall">
            <a class="phone" href="tel:1-510-888-1159">call</a> 
            <button class="mail" onclick="sendMail()">mail</button><br> <br> <br> <br> <br>
        </div>

Javascript (basic vanilla not jquery)

function sendMail() {
var userEmail = document.getElementById("userEmail").value;
var subject = document.getElementById("subject").value;
var message = subject = document.getElementById("message").value;
window.open('mailto:markreggiardo@gmail.com?cc=' + userEmail + '&subject=' + subject + '&body=' + message);

}




Aucun commentaire:

Enregistrer un commentaire