Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Dec 2009
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    form mailto with checkboxes?

    I have a question and I'm hoping someone may have some suggestions on how to solve.

    I found a script on this forum that does almost what I want from this thread:
    http://codingforums.com/showthread.php?t=184011 (thank you Philip M!)

    Instead of a dropdown, I'd like to have a list of names using check boxes, so that you have the option to send an email to one or all of the people. When you choose your selections and click submit, an outlook email will pop up with your selections in the to: field.

    Is this possible?

    Here's the solutuin using a drop down, this works (and works well), but doesn't quite do what I need :

    <form name="Contact_Us" id="contact" method="post" enctype="text/plain" onsubmit = "getEml()">
    <fieldset id="selection">
    Who would you would like to email:
    <select name = "sel">
    <option value="email1@email.com" >email 1</option>
    <option value="email2@email.com" >email 2</option>
    <option value="email3@email.com" >email 3</option>
    </select>
    <input type = "submit" value = "Submit the form">
    </form>

    <script type = "text/javascript">
    function getEml() {
    var emailaddress = document.Contact_Us.sel.value;
    window.location = "mailto:" + emailaddress;
    }

    </script>

    Is there a way to use checkboxes but to do the same thing?

    <INPUT TYPE=CHECKBOX NAME="name1@email.com">name 1<BR>
    <INPUT TYPE=CHECKBOX NAME="name2@email.com">name 2<BR>
    <INPUT TYPE=CHECKBOX NAME="name3@email.com">name 3<BR>

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,733
    Thanks
    202
    Thanked 2,508 Times in 2,486 Posts
    "Once more unto the breach, dear friends, once more" - Shakespeare, Henry V Act III.

    Code:
    <form name="Contact_Us" id="contact" method="post" enctype="text/plain" onsubmit = "getEml()">
    
    Who would you would like to email:<br>
    <input type = "checkbox" name = "cbox" value="name1@email.com">name 1<br>
    <input type = "checkbox" name = "cbox" value="name2@email.com">name 2<br>
    <input type = "checkbox" name = "cbox" value="name3@email.com">name 3<br> 
    <input type = "submit" value = "Submit the form">
    </form> 
    
    <script type = "text/javascript">
    function getEml() {
    var emailaddress = "";
    var boxes = document.Contact_Us.cbox.length;
    for (i = 0; i < boxes; i++) {
    if (document.Contact_Us.cbox[i].checked) {
    emailaddress= emailaddress + document.Contact_Us.cbox[i].value;
    emailaddress += ";" ;
    }
    }
    if (emailaddress == "") {
    alert ("Please check one or more boxes!");
    return false
    }
    window.location = "mailto:" + emailaddress; 
    }
    
    </script>
    I take it that you realise that putting un-encrypted or un-obfuscated email adrresses in a web page exposes those recipients to a torrent of spam.


    "I used to think I was poor. Then they told me I wasn't poor, I was needy. Then they told me it was self-defeating to think of myself as needy. I was deprived. (Oh not deprived but rather underprivileged.) Then they told me that underprivileged was overused. I was disadvantaged. I still don't have a dime. But, I have a great vocabulary." - Jules Feiffer, cartoonist.
    Last edited by Philip M; 12-09-2009 at 10:22 AM. Reason: Typo

  • Users who have thanked Philip M for this post:

    leaflover (12-09-2009)

  • #3
    New to the CF scene
    Join Date
    Dec 2009
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts
    I do realize it would open up a world of trouble for these users if this was an open website. But it's internal to a company, behind a firewall, with no access from any external users whatsoever. So I think it's safe from the perils of spam.

    Thank you!


    “Appreciation is a wonderful thing. It makes what is excellent in others belong to us as well.” - Voltaire


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •