www.webdeveloper.com
Results 1 to 5 of 5

Thread: email dropdown menu

  1. #1
    Join Date
    Oct 2010
    Posts
    25

    email dropdown menu

    I'm trying to create a button that you push and it takes you to a page that has the following:

    dropdown menu (displays emails)
    a subject
    comments
    and a submit button

    what I want it to do is you pick an email. put a subject in and cilck the button and it sens.

    this is the information I have..

    HTML Code:
    <form action="email.php">
    	<input type="submit name="email">
    that brings me to the page with the dropdown menu, subject, comments and submit button..

    HTML Code:
    <html>
    <head></head>
    
    <body>
    
    <br />
    
    To:
    <select>
      <option value="email">man@hotmail.com</option>
      <option value="email2">dumb@rogers.com</option>
      <option value="email3">junk@mts,net</option>
      <option value="email4">test@mts.net</option>
    </select> 
    
    <br />
    from:<input type="text" name="email"> <br />
    Subject:<textarea> </textarea> <br />
    <input type="submit"> 
    
    
    </body>
    </html>
    this is that page I was mentioning..

    and this is the code I have been trying to figure out how to put it all together...

    HTML Code:
    <?php 
    $name = $_POST['name'];
    $email = $_POST['email'];
    $message = $_POST['message'];
    $formcontent="From: $name \n Message: $message";
    $recipient = "emailaddress@here.com<script type="text/javascript">
    /* <![CDATA[ */
    (function(){try{var s,a,i,j,r,c,l=document.getElementById("__cf_email__");a=l.className;if(a){s='';r=parseInt(a.substr(0,2),16);for(j=2;a.length-j;j+=2){c=parseInt(a.substr(j,2),16)^r;s+=String.fromCharCode(c);}s=document.createTextNode(s);l.parentNode.replaceChild(s,l);}}catch(e){}})();
    /* ]]> */
    </script>";
    $subject = "Contact Form";
    $mailheader = "From: $email \r\n";
    mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
    echo "Thank You!";
    ?>
    if anyone can help me with this that would be super! its driving me nuts!

  2. #2
    Join Date
    Aug 2008
    Location
    Phoenix, AZ
    Posts
    84
    Not to nit-pick, but why do you have a javascript call at your $recipient variable? I would figure that having another set of " would break your code and wouldn't get past that point. Besides, from what I know, most mail clients like gmail will strip out any javascript that's sent.

    Also, and this is just my dumb self talking, I didn't really get what your problem was. I got the code and read it, but you never really stated what the problem was. Anyway, hope that helps.

    Quote Originally Posted by D1Lu5IoN View Post
    I'm trying to create a button that you push and it takes you to a page that has the following:

    dropdown menu (displays emails)
    a subject
    comments
    and a submit button

    what I want it to do is you pick an email. put a subject in and cilck the button and it sens.

    this is the information I have..

    HTML Code:
    <form action="email.php">
    	<input type="submit name="email">
    that brings me to the page with the dropdown menu, subject, comments and submit button..

    HTML Code:
    <html>
    <head></head>
    
    <body>
    
    <br />
    
    To:
    <select>
      <option value="email">man@hotmail.com</option>
      <option value="email2">dumb@rogers.com</option>
      <option value="email3">junk@mts,net</option>
      <option value="email4">test@mts.net</option>
    </select> 
    
    <br />
    from:<input type="text" name="email"> <br />
    Subject:<textarea> </textarea> <br />
    <input type="submit"> 
    
    
    </body>
    </html>
    this is that page I was mentioning..

    and this is the code I have been trying to figure out how to put it all together...

    PHP Code:
    <?php 
    $name 
    $_POST['name'];
    $email $_POST['email'];
    $message $_POST['message'];
    $formcontent="From: $name \n Message: $message";
    $recipient "emailaddress@here.com<script type="text/javascript">
    /* <![CDATA[ */
    (function(){try{var s,a,i,j,r,c,l=document.getElementById("
    __cf_email__");a=l.className;if(a){s='';r=parseInt(a.substr(0,2),16);for(j=2;a.length-j;j+=2){c=parseInt(a.substr(j,2),16)^r;s+=String.fromCharCode(c);}s=document.createTextNode(s);l.parentNode.replaceChild(s,l);}}catch(e){}})();
    /* ]]> */
    </script>"
    ;
    $subject "Contact Form";
    $mailheader "From: $email \r\n";
    mail($recipient$subject$formcontent$mailheader) or die("Error!");
    echo 
    "Thank You!";
    ?>
    if anyone can help me with this that would be super! its driving me nuts!

  3. #3
    Join Date
    Oct 2010
    Posts
    25
    my problem is that I can't get figure out how to get the dropdown menu to work with the php so it will send to the email addresses.

  4. #4
    Join Date
    Aug 2008
    Location
    Phoenix, AZ
    Posts
    84
    Oh, then that's easy. Name your SELECT tag and then put the values of the email address you want as the options.
    HTML Code:
    <select id="emailTo" name="emailTo">
      <option value="man@hotmail.com">man@hotmail.com</option>
      <option value="dumb@rogers.com">dumb@rogers.com</option>
      <option value="junk@mts.net">junk@mts.net</option>
      <option value="test@mts.net">test@mts.net</option>
    </select> 
    Then in your PHP, you look for your select tag in post.
    PHP Code:
    $emailTo $_POST['emailTo']; 

  5. #5
    Join Date
    Oct 2010
    Posts
    25
    that seems easy enough..

    is there way to have it so when they hit the button a file is called (new page) with the drop menu and the emails on that file automatically appear in the drop down menu? so all they do is select the email fill in the blanks and push send.

    I'm not sure if that makes any sense or not..

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles