Page 1 of 4 123 ... LastLast
Results 1 to 10 of 38

Thread: Javascripts to send email to many recipients

  1. #1
    Join Date
    Aug 2006
    Posts
    34
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Javascripts to send email to many recipients

    Hi guys! Can anybody help me? I am not sure whether the script that I am going to describe below has ever been written or not, but i couldn't find such script anywhere. The main purpose of the script that I wanted below is to save my time typing the names of recipients of my email.
    I have about 60 students in my class and i have all their email addresses. What I want to do is to have a web page (lets call this the "master page")with all their names listed in it, and next to each of their names are check box. Whenever I want to send email to some of them (say, to about 30 of them), I just check the box next to their names. After that, when i push a button (say, labelled "next"), my default email's "compose box" will appear with all the selected names listed as recipients of my email.
    I would also like to have a "select all" check box on the master page so that whenever I want to send an email to all my students, i just check the "select all" box and all their names will be listed as recipients in my email's compose box.
    I hope you guys can understand my description above.

  2. #2
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    Id all of the checkboxes a1, a2, a3, etc.

    Store them in an array, and call them in a loop:
    Code:
    <script type="text/javascript">
    var boxes = new Array("a1","a2","a3","a4","a5","a6")
    function checkall() {
    for (i=0;i<=boxes.length-1;i++) {
    var allboxes = document.getElementById(boxes[i])
    allboxes.checked=true
    }
    }
    </script>
    - Mike

  3. #3
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    This would be an example of the full script:

    Code:
    <html>
    <head>
    <script type="text/javascript">
    var boxes = new Array("a1","a2","a3","a4","a5","a6")
    function checkall() {
    for (i=0;i<=boxes.length-1;i++) {
    var allboxes = document.getElementById(boxes[i])
    if (allboxes.checked==false) {allboxes.checked=true}
    else {allboxes.checked=false}
    }
    }
    </script>
    </head>
    <body>
    <input type="button" value="Check/Uncheck All" onclick="checkall()">
    <br><input type="checkbox" id="a1">Student 1
    <br><input type="checkbox" id="a2">Student 2
    <br><input type="checkbox" id="a3">Student 3
    <br><input type="checkbox" id="a4">Student 4
    <br><input type="checkbox" id="a5">Student 5
    <br><input type="checkbox" id="a6">Student 6
    </body>
    </html>
    - Mike

  4. #4
    Join Date
    Aug 2006
    Posts
    34
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by mburt
    This would be an example of the full script:

    Code:
    <html>
    <head>
    <script type="text/javascript">
    var boxes = new Array("a1","a2","a3","a4","a5","a6")
    function checkall() {
    for (i=0;i<=boxes.length-1;i++) {
    var allboxes = document.getElementById(boxes[i])
    if (allboxes.checked==false) {allboxes.checked=true}
    else {allboxes.checked=false}
    }
    }
    </script>
    </head>
    <body>
    <input type="button" value="Check/Uncheck All" onclick="checkall()">
    <br><input type="checkbox" id="a1">Student 1
    <br><input type="checkbox" id="a2">Student 2
    <br><input type="checkbox" id="a3">Student 3
    <br><input type="checkbox" id="a4">Student 4
    <br><input type="checkbox" id="a5">Student 5
    <br><input type="checkbox" id="a6">Student 6
    </body>
    </html>
    Thanks, but your scripts only take care of the first part of the process i.e. to select the recipients. The second part of the process is to upload the selected people's email addresses into my email's compose box. I am not sure whether this can be done by javascripts.

  5. #5
    Join Date
    Aug 2006
    Posts
    34
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by terkini
    Thanks, but your scripts only take care of the first part of the process i.e. to select the recipients. The second part of the process is to upload the selected people's email addresses into my email's compose box. I am not sure whether this can be done by javascripts.
    Can anybody help me to come up with the script to upload/transfer the email address of the selected people into my email's "compose" box? I roughly know that the function is "onSubmit" but I don't know how to write it.

  6. #6
    Join Date
    Jun 2006
    Posts
    182
    Thanks
    0
    Thanked 14 Times in 14 Posts

    Default

    You can't transfer emails with javascript, you need some server side scripting to do that.

  7. #7
    Join Date
    Aug 2006
    Posts
    34
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by DimX
    You can't transfer emails with javascript, you need some server side scripting to do that.
    Really?? I thought sometime ago i come across a javascript that can call-up the email's "compose" box with the subject and the recipient's name on it, and all you have to do is push the "send" button.

  8. #8
    Join Date
    Jun 2006
    Posts
    182
    Thanks
    0
    Thanked 14 Times in 14 Posts

    Default

    Oh, you mean that, it's just a link:
    Code:
    <a href="mailto:mymail@mail.com?subject=Hallo%20there...&body=Message%20body%20comes%20here.">Email me</a>
    But yes, if you want to capture user input first then you'll need to use javascript.

    Here, I made you a small example: http://roboweb.awardspace.com/email.html
    Last edited by DimX; 08-23-2006 at 12:08 PM.

  9. #9
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by terkini
    Really?? I thought sometime ago i come across a javascript that can call-up the email's "compose" box with the subject and the recipient's name on it, and all you have to do is push the "send" button.
    You are referring to mailto links. These are unreliable and shouldn't be used to pre-compose an e-mail: they rely on the user having a mail client installed (not always the case for shared machines and irrelevant to visitors that would use a Web interface like Hotmail or Gmail), a browser that understands the mailto scheme, and an established relationship between the two.

    The use of form mail - using the server to send mail - only depends upon the HTTP protocol (which is guaranteed).

    Mike

  10. #10
    Join Date
    Jun 2006
    Posts
    182
    Thanks
    0
    Thanked 14 Times in 14 Posts

    Default

    Quote Originally Posted by mwinter
    You are referring to mailto links. These are unreliable and shouldn't be used to pre-compose an e-mail: they rely on the user having a mail client installed (not always the case for shared machines and irrelevant to visitors that would use a Web interface like Hotmail or Gmail), a browser that understands the mailto scheme, and an established relationship between the two.
    I don't believe (s)he wants to publish that page, (s)he just wants to simplify the way (s)he sends mails to students.

Bookmarks

Posting Permissions

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