mardi 20 décembre 2016

need help modifying my current checkbox to mailto script

i have setup a bunch of checkboxes on our website next to products and when they click submit after choosing their options it opens up the email client with a pre formatted email automatically filled in with the options selected. However there are a couple things id like to change/add but my knowledge is basic when it comes to javascript.

Submit button:

<button onclick="sendMail(); return false">Request Quote</button></div>

Checkbox:

<label><div id="checkboxarea"><input type="checkbox" name="product 1" />buy</label>

Script:

<script type='text/javascript' src='http://ift.tt/Y75GEe'></script>
        <script type='text/javascript' src='http://ift.tt/2h6cy8Y'></script>
        <script type='text/javascript'>
          function sendMail() {
            var mailbody = "I would like a quote for the following titles: \n\n"
                           + $('input[type="checkbox"]').map(
                                function(id, box){ return (box.checked ? "[x]" : "[ ]") + " " + box.name;}
                              ).get().join("\n");
            var link = "mailto:email@example.com"
                        + "?cc=myCCaddress@example.com"
                        + "&subject=" + escape("SCREENERS: REQUEST QUOTE")
                        + "&body=" + escape(mailbody);
            window.location.href = link;
          }

          $(function(){
            $( "#checklist" ).sisyphus();
          });
        </script>

i'd like to change (if possible) when the email is generated it currently includes all the option that weren't selected, for example:

[x] product 1
[x] product 2
[ ] product 3
[ ] product 4
[x] product 5

is it possible to only add the selected products to the email?

also i'd like to add a text area field so they can add a comment/note that will also be added to the email along with the options when they click submit




Aucun commentaire:

Enregistrer un commentaire