SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Mar 2011
    0 Post(s)
    0 Thread(s)

    two actions for one form submit

    I have a javascript code to let people subscribe to our newsletter.
    I would like to get a mail each time a person get subscribed to our newsletter.

    The code to let people subscribed to our newsletter is:

    [I] <!-- newsletter subscribe below here -->
    <script language="Javascript" type="text/javascript">
    var fieldstocheck = new Array();
    fieldnames = new Array();
    function checkform() {
    for (i=0;i<fieldstocheck.length;i++) {
    if (eval("document.subscribeform.elements['"+fieldstocheck[i]+"'].value") == "") {
    alert("Please enter your "+fieldnames[i]);
    return false;
    return true;
    function addFieldToCheck(value,name) {
    fieldstocheck[fieldstocheck.length] = value;
    fieldnames[fieldnames.length] = name;
    <form action=";id=2" method="post" name="subscribeform">
    <p class="linkleft12">Our Newsletter/p>
    <p class="linkleft12">Email:
    <input name="email" style="width: 105px" type="text" value="" />
    <script language="Javascript" type="text/javascript">addFieldToCheck("email","Email Address");</script>
    <input name="list[2]" type="hidden" value="signup" /></p>
    <p class="linkleft12">
    <input name="subscribe" onclick="return checkform();" type="submit" value="Subscribe" /></p>
    <!-- newsletter subscribe ends here -->

    I also would like that an e-mail is send automatically to

    Thanks for your help.


  2. #2
    SitePoint Wizard Stomme poes's Avatar
    Join Date
    Aug 2007
    51 Post(s)
    2 Thread(s)
    I'm a little confused why Javascript is necessary to let people sign up to the newsletter. Is it to keep out bots?

    Normally someone would have one single back-end script attached to the signup form who dealt with both setting up the user's email for regular mails, and sending you a notification.

    Holy cow, another Matt Script clone : ) If you've got anything more than the most basic form or two, you might want to invest in a nice small Perl backend that just has the mail stuff and notification stuff... without anything smelling like Matt's Scripts (I'm glad to hear it doesn't use any of his code : ) Something like... CGI::Application or maybe a framework like Mojolicious?

    I know this doesn't answer your questions at all, but you're using Perl and that's awesome so I had to say something : )


Posting Permissions

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