www.webdeveloper.com
Results 1 to 6 of 6

Thread: Javascript to send unordered list to email

  1. #1
    Join Date
    Mar 2012
    Posts
    13

    Javascript to send unordered list to email

    I have this code below to be set up just like a form SELECT and OPTION. I am not the best with Javascript, but I am looking for a script that would send an email of whatever the user selects. Everything else is set up form wise and with the php. Any help would be greatly appreciated, thanks. Basically just looking for the script that would pull the option in which the user chooses and then sending that to an email. There is no javascript so this would be from scratch, I have the slightest clue of where to start.

    HTML Code:
    <div id="dd" class="wrapper-dropdown-3 menu-869" tabindex="1">
    						<span>Transport</span>
    							<ul class="dropdown" name="menu-869">
    								<li><a href="#" value="Classic Mail"><i class="icon-envelope icon-large"></i>Classic mail</a></li>
    								<li><a href="#" value="UPS Delivery"><i class="icon-truck icon-large"></i>UPS Delivery</a></li>
    								<li><a href="#" value="Private Jet"><i class="icon-plane icon-large"></i>Private jet</a></li>
    							</ul>
    					</div>

  2. #2
    Join Date
    Sep 2008
    Location
    Akron, OH
    Posts
    1,129
    Javascript cannot send an email. You'll have to use PHP.
    I'm always up for networking with fellow web professionals. Connect with me on LinkedIn if you like!

  3. #3
    Join Date
    Mar 2012
    Posts
    13
    Quote Originally Posted by cbVision View Post
    Javascript cannot send an email. You'll have to use PHP.
    Then how would you pull an unordered list value to send in an email with PHP?

    would something like this work?
    PHP Code:
    $body .= "Email: ".$_REQUEST['Email']." \n"
    just give the unordered list a name to call?

  4. #4
    Join Date
    Sep 2008
    Location
    Akron, OH
    Posts
    1,129
    Typically, you'd submit your data to a PHP file using a form. For example:

    Code:
    <form method="post" action="email.php">
    	<input name="email" type="text" />
    	<input type="submit" />
    </form>
    Your mail.php would look something like this:
    Code:
    <?php
    	$to = $_REQUST['email'];
    	$subject = "Test mail";
    	$message = "Hello! This is a simple email message.";
    	$from = "someonelse@example.com";
    	$headers = "From:" . $from;
    	mail($to,$subject,$message,$headers);
    	echo "Mail Sent.";
    ?>
    I'm always up for networking with fellow web professionals. Connect with me on LinkedIn if you like!

  5. #5
    Join Date
    Mar 2012
    Posts
    13
    Thank you very much for your help. I will see what I can do.

  6. #6
    Join Date
    Sep 2008
    Location
    Akron, OH
    Posts
    1,129
    Here's a example of how you could pass the value of a list item to a hidden form value then submit the form when it's clicked:
    http://jsfiddle.net/cgYxn/3/
    I'm always up for networking with fellow web professionals. Connect with me on LinkedIn if you like!

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