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 4 of 4
  1. #1
    New Coder
    Join Date
    Oct 2011
    Posts
    92
    Thanks
    38
    Thanked 0 Times in 0 Posts

    Question mailto does not attach the form information.

    Attached is the code. It does open the email but does not send any information.
    Can someone please assist.

    Code:
    <!-- Table 2 for the Content -->
    <form name="orders" onsubmit="return confirmSubmit()" onreset="return window.confirm('Are you sure you want to reset your Orders.'); " action="mailto:lynette@sayorkies.co.za" method="post" enctype="text/plain">
    Code:
    // Function to Confirm certain conditions and confirm to proceed with order
    function confirmSubmit() {
    	var itemsOrdered = true;
    	if (document.forms[2].totalExcl.value == 0 || document.forms[2].delivery.value == 0) {
    	itemsOrdered = false;
    	}
    	if(itemsOrdered != true) {
    	window.alert("You have not chosen any products to purchase or No Delivery Option selected.");
    	return false;
    	}
    	var submitOrder = window.confirm("Are you sure you want to place the order?");
    	if(submitOrder == true)
    	return true;
    	return false;
    	}
    
    // Function to calculate order value 
    function calculateValue(orders) {
    	var orderValue = 0;
     
    	// Run through all the product fields
    	for(var i = 0; i < orders.elements.length; ++i) {
     
    	// Get the current field
    	var formField = orders.elements[i];
     
    	// Get the fields name
    	var formName = formField.name;
    	
    	// Is it a "product" field?
            if (formName.substring(0,4) == "prod") {
     
    	// Items price extracted from name
    	var itemPrice = parseFloat(formName.substring(formName.lastIndexOf("_") + 1));
     
    	// Get the Quantity
    	var itemQuantity = parseInt(formField.value);
     
    	// Update the OrderValue
    	if(itemQuantity >= 0) {
    	orderValue += itemQuantity * itemPrice;
    	}
    	}
        }
    	
    	// Display the totals
        orders.totalExcl.value = "R " + orderValue.toLocaleString();
        
        // function to calculate VAT at 15% as required and total inclusive.
    	function calcTotals(oValue) {
    	var vat = oValue * .15;
    	var totalIncluding = oValue + vat;
    	var tDelivery = Number( orders.delivery.value.substring(2) );
    	var theTotalOrder = totalIncluding + tDelivery;
    	orders.vat.value = "R " + vat.toLocaleString();
    	orders.totalIncl.value = "R " + totalIncluding.toLocaleString();
    	orders.totalOrder.value = "R " + theTotalOrder.toLocaleString();
    	}
    	return calcTotals(orderValue);
    }
    Last edited by hans_cellc; 10-05-2011 at 06:58 PM. Reason: Email notification

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,910
    Thanks
    203
    Thanked 2,531 Times in 2,509 Posts
    The trouble with using this method (mailto) to send form results is its unpredictability. The method it is highly dependent on the browser in use and the email client in use (some people have only Yahoo or Hotmail). In particular, your visitor must have Outlook or Outlook Express as the default client for this to work correctly. Even if your visitor is using Internet Explorer, but the default mail client is different (e.g. Eudora), your mailto form will not work. With all of the browser troubles, you're likely to lose about half of your users' messages. Most of the email clients that can successfully send a mail will prompt the user by a security dialog prior to sending - this can scare many users from continuing.

    In fact few browsers these days accept mailto: as a form action. You need a really old browser for it to work as more modern browsers simply open the email program (if any) and ignore the form. If you are going to use a form then use a server-side formmail script as the action - there are several good free ones out there.


    All advice is supplied packaged by intellectual weight, and not by volume. Contents may settle slightly in transit.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  • Users who have thanked Philip M for this post:

    hans_cellc (10-05-2011)

  • #3
    New Coder
    Join Date
    Oct 2011
    Posts
    92
    Thanks
    38
    Thanked 0 Times in 0 Posts
    Thanks, I tried and looked at CGI but had a .exe file to run and that scares me even more.

    Any suggestions, in the meantime I am googling "server-side formmail script"

    Thanks.

  • #4
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,910
    Thanks
    203
    Thanked 2,531 Times in 2,509 Posts
    For a simple PHP form feedback script see:- http://www.thesitewizard.com/archive/feedbackphp.shtml

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  • Users who have thanked Philip M for this post:

    hans_cellc (10-05-2011)


  •  

    Tags for this Thread

    Posting Permissions

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