Javascript 不使用ajax传递post的变量

Javascript 不使用ajax传递post的变量,javascript,php,jquery,ajax,Javascript,Php,Jquery,Ajax,我试过几种不同的方法,但我还是坚持着。我有一个模态中的表单,它可以滑出来订购一些零件。提交表单后,它将通过javascript测试,然后发布到php页面,向公司发送电子邮件订购零件。除了两件事外,我让它工作。单选按钮(三个)显示身份不明,“城市”文本为空。这是代码,并提供了指向页面的链接 形式 php 感谢您的订单 我们将打电话确认您的订单并接受付款。 请查看以上订单,如果不正确,请致电(281)970-1200。 信息发送日期: 您链接的页面上没有表单,或者我遗漏了什么?也。。。看起来这就

我试过几种不同的方法,但我还是坚持着。我有一个模态中的表单,它可以滑出来订购一些零件。提交表单后,它将通过javascript测试,然后发布到php页面,向公司发送电子邮件订购零件。除了两件事外,我让它工作。单选按钮(三个)显示身份不明,“城市”文本为空。这是代码,并提供了指向页面的链接

形式

php


感谢您的订单
我们将打电话确认您的订单并接受付款。


请查看以上订单,如果不正确,请致电(281)970-1200。


信息发送日期:


您链接的页面上没有表单,或者我遗漏了什么?也。。。看起来这就是您的全部代码(或者说非常接近)。你能提供一个更简单的例子吗?这样你就更有可能得到质量更好的帮助。当然我会尽量减少。表单位于页面右上角的下拉列表中。抱歉,我刚意识到你需要去谢谢。。。我将等待精简版本。:-)
//declare our variables
    $name = $_POST['name'];
    $email = $_POST['email'];
    $phone = $_POST['phone'];
    $address = $_POST['address'];
    $city = $_POST['city'];
    $state = $_POST['state'];
    $zipcode = $_POST['zipcode'];
    $supplier1 = $_POST['supplier1'];
    $supplier2 = $_POST['supplier2'];
    $supplier3 = $_POST['supplier3'];
    $supplier4 = $_POST['supplier4'];
    $qty1 = $_POST['qty1'];
    $qty2 = $_POST['qty2'];
    $qty3 = $_POST['qty3'];
    $qty4 = $_POST['qty4'];
    $p_number1 = $_POST['p_number1'];
    $p_number2 = $_POST['p_number2'];
    $p_number3 = $_POST['p_number3'];
    $p_number4 = $_POST['p_number4'];
    $message = nl2br($_POST['message']);
    //get todays date
    $todayis = date("l, F j, Y, g:i a") ;
    //set a title for the message
    $subject = "Parts Order From ARH Cycles";
    $body_message = '<html><body style="color:#FFFFFF; background-color: #850000">';
    $body_message .= '<table border="1" bordercolor="#ffffff" cellpadding="10">';
    $body_message .= '<tr style="background: #850000;"><td><strong>From:</strong>     </td><td>'.$name.'</td></tr>';
    $body_message .= '<tr style="background: #850000;"><td><strong>Email:</strong> </td><td>'.$email.'</td></tr>';
    $body_message .= '<tr style="background: #850000;"><td><strong>Phone:</strong> </td><td>'.$phone.'</td></tr>';
    $body_message .= '<tr style="background: #850000;"><td><strong>Address:</strong> </td><td>'.$address .'</td></tr>';
    $body_message .= '<tr style="background: #850000;"><td><strong>City:</strong> </td><td>'.$city.'</td></tr>';
    $body_message .= '<tr style="background: #850000;"><td><strong>State:</strong> </td><td>'.$state.'</td></tr>';
    $body_message .= '<tr style="background: #850000;"><td><strong>Zipcode:</strong> </td><td>'.$zipcode .'</td></tr>';
    $body_message .= '</table>';
    $body_message .= '<table border="1" bordercolor="#ffffff" cellpadding="10">';
    $body_message .= '<tr style="background: #850000;"><td><strong>Supplier:</strong></td><td>' .$supplier1.'</td><td><strong>Quanity:</strong> </td><td>'.$qty1.'</td><td><strong>Part Number:</strong></td><td>'.$p_number1.'</td></tr>';
    $body_message .= '<tr style="background: #850000;"><td><strong>Supplier:</strong></td><td> ' .$supplier2.'</td><td><strong>Quanity:</strong> </td><td>'.$qty2.'</td><td><strong>Part Number:</strong></td><td>'.$p_number2.'</td></tr>';
    $body_message .= '<tr style="background: #850000;"><td><strong>Supplier:</strong></td><td>' .$supplier3.'</td><td><strong>Quanity:</strong> </td><td>'.$qty3.'</td><td><strong>Part Number:</strong></td><td>'.$p_number3.'</td></tr>';
    $body_message .= '<tr style="background: #850000;"><td><strong>Supplier:</strong></td><td>' .$supplier4 .'</td><td><strong>Quanity:</strong> </td><td>'.$qty4.'</td><td><strong>Part Number:</strong></td><td>'.$p_number4.'</td></tr>';
    $body_message .= '</table>';
    $body_message .= '<table border="1" bordercolor="#ffffff" cellpadding="10">';
    $body_message .= '<tr style="background: #850000;"><td colspan="3"><strong>Message:</td></tr>';
    $body_message .= '<tr style="background: #850000;"><td rowspan="3"colspan="3">' .$message .'</td></tr>';
    $body_message .= '</table>';
    $body_message .= '</body></html>'; 
    $headers = "From: " .$email . "r\n" ;
    $headers .= "Reply-To: ".$email . "\n";
    $headers .= "MIME-Version: 1.0\r\n";
    $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";                   


    //put your email address here
    mail("email@yourdomain.com, $email", $subject, $body_message, $headers);
    ?>
   <!--Display a thankyou message in the callback -->
   <div id="mail_response">
   <h3>Thank you for your order&nbsp<?php echo $name ?>!</h3><br />
   <p>We will be calling to verify your order and take payment.</p><br />
   <p>Please look over your order above and call (281) 970-1200 if incorrect.</p><br />
   <h5>Message sent on: </h5>
   <p><?php echo $todayis ?></p>
    $(document).ready(function(){
//function for contact form dropdown
 function contact() {
    if ($("#contactForm").is(":hidden")){
        $("#contactForm").slideDown("slow");
        $("#backgroundPopup").css({"opacity": "0.7"});
        $("#backgroundPopup").fadeIn("slow"); 
     }
     else{
        $("#contactForm").slideUp("slow");
        $("#backgroundPopup").fadeOut("slow");  
    }
        }

    //run contact form when any contact link is clicked
$(".contact").click(function(){contact()});

//animation for same page links #
$('a[href*=#]').each(function() {
    if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
    && location.hostname == this.hostname
    && this.hash.replace(/#/,'') ) {
      var $targetId = $(this.hash), $targetAnchor = $('[name=' + this.hash.slice(1) +']');
      var $target = $targetId.length ? $targetId : $targetAnchor.length ? $targetAnchor : false;
        if ($(this.hash).length) {
            $(this).click(function(event) {
                var targetOffset = $(this.hash).offset().top;
                var target = this.hash;
                event.preventDefault();            
                $('html, body').animate({scrollTop: targetOffset}, 500);
                return false;
            });
        }
    }
    });



    //submission scripts
    $('.contactForm').submit( function(){
    //statements to validate the form   
    var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
    var email = document.getElementById('e-mail');
    if (!filter.test(email.value)) {
        $('.email-missing').show();
    } else {$('.email-missing').hide();}
    if (document.cform.name.value == "") {
        $('.name-missing').show();
    } else {$('.name-missing').hide();} 
    if (document.cform.message.value == "") {
        $('.message-missing').show();
    } else {$('.message-missing').hide();}      
    if ((document.cform.name.value == "") || (!filter.test(email.value)) || (document.cform.phone.value == "")){
        return false;
    } 

    if ((document.cform.name.value != "") && (filter.test(email.value)) && (document.cform.phone.value != "")) {
        //hide the form
        $('.contactForm').hide();

        //show the loading bar
        $('.loader').append($('.bar'));
        $('.bar').css({display:'block'});

        //send the ajax request
        $.post('includes/mail.php',{name:$('#name').val(),

    email:$('#e-mail').val(),

    phone:$('#phone').val(),
                                    address:$('#address').val(),
                                    city:$('#city').val(),
                                    state:$('#state').val(),
                                    zipcode:$('#zipcode').val(),
                                    supplier1:$('#supplier1').val(),
                                    qty1:$('#qty1').val(),
                                    p_number1:$('#p_number1').val(),
                                    supplier2:$('#supplier2').val(),
                                    qty2:$('#qty2').val(),
                                    p_number2:$('#p_number2').val(),
                                    supplier3:$('#supplier3').val(),
                                    qty3:$('#qty3').val(),
                                    p_number3:$('#p_number3').val(),
                                    supplier4:$('#supplier4').val(),
                                    qty4:$('#qty4').val(),
                                    p_number4:$('#p_number4').val(),
                                    message:$('#message').val()},

        //return the data
        function(data){
          //hide the graphic
          $('.bar').css({display:'none'});
          $('.loader').append(data);
        });

        //waits 2000, then closes the form and fades out
        setTimeout('$("#backgroundPopup").fadeOut("slow"); $("#contactForm").slideUp("slow")', 4000);

        //stay on the page
        return false;
    } 
    });
//only need force for IE6  
$("#backgroundPopup").css({  
    "height": document.documentElement.clientHeight 
});  
    });
   <?php
    //declare our variables
    $name = $_POST['name'];
    $email = $_POST['email'];
    $phone = $_POST['phone'];
    $address = $_POST['address'];
    $city = $_POST['city'];
    $state = $_POST['state'];
    $zipcode = $_POST['zipcode'];
    $supplier1 = $_POST['supplier1'];
    $supplier2 = $_POST['supplier2'];
    $supplier3 = $_POST['supplier3'];
    $supplier4 = $_POST['supplier4'];
    $qty1 = $_POST['qty1'];
    $qty2 = $_POST['qty2'];
    $qty3 = $_POST['qty3'];
    $qty4 = $_POST['qty4'];
    $p_number1 = $_POST['p_number1'];
    $p_number2 = $_POST['p_number2'];
    $p_number3 = $_POST['p_number3'];
    $p_number4 = $_POST['p_number4'];
    $message = nl2br($_POST['message']);
    //get todays date
    $todayis = date("l, F j, Y, g:i a") ;
    //set a title for the message
    $subject = "Parts Order From ARH Cycles";
    $body_message = '<html><body style="color:#FFFFFF; background-color: #850000">';
    $body_message .= '<table border="1" bordercolor="#ffffff" cellpadding="10">';
    $body_message .= '<tr style="background: #850000;"><td><strong>From:</strong> </td><td>'.$name.'</td></tr>';
    $body_message .= '<tr style="background: #850000;"><td><strong>Email:</strong> </td><td>'.$email.'</td></tr>';
    $body_message .= '<tr style="background: #850000;"><td><strong>Phone:</strong> </td><td>'.$phone.'</td></tr>';
    $body_message .= '<tr style="background: #850000;"><td><strong>Address:</strong> </td><td>'.$address .'</td></tr>';
    $body_message .= '<tr style="background: #850000;"><td><strong>City:</strong> </td><td>'.$city.'</td></tr>';
    $body_message .= '<tr style="background: #850000;"><td><strong>State:</strong> </td><td>'.$state.'</td></tr>';
    $body_message .= '<tr style="background: #850000;"><td><strong>Zipcode:</strong> </td><td>'.$zipcode .'</td></tr>';
    $body_message .= '</table>';
    $body_message .= '<table border="1" bordercolor="#ffffff" cellpadding="10">';
    $body_message .= '<tr style="background: #850000;"><td><strong>Supplier:</strong></td><td>' .$supplier1.'</td><td><strong>Quanity:</strong> </td><td>'.$qty1.'</td><td><strong>Part Number:</strong></td><td>'.$p_number1.'</td></tr>';
    $body_message .= '<tr style="background: #850000;"><td><strong>Supplier:</strong></td><td> ' .$supplier2.'</td><td><strong>Quanity:</strong> </td><td>'.$qty2.'</td><td><strong>Part Number:</strong></td><td>'.$p_number2.'</td></tr>';
    $body_message .= '<tr style="background: #850000;"><td><strong>Supplier:</strong></td><td>' .$supplier3.'</td><td><strong>Quanity:</strong> </td><td>'.$qty3.'</td><td><strong>Part Number:</strong></td><td>'.$p_number3.'</td></tr>';
    $body_message .= '<tr style="background: #850000;"><td><strong>Supplier:</strong></td><td>' .$supplier4 .'</td><td><strong>Quanity:</strong> </td><td>'.$qty4.'</td><td><strong>Part Number:</strong></td><td>'.$p_number4.'</td></tr>';
    $body_message .= '</table>';
    $body_message .= '<table border="1" bordercolor="#ffffff" cellpadding="10">';
    $body_message .= '<tr style="background: #850000;"><td colspan="3"><strong>Message:</td></tr>';
    $body_message .= '<tr style="background: #850000;"><td rowspan="3"colspan="3">' .$message .'</td></tr>';
    $body_message .= '</table>';
    $body_message .= '</body></html>'; 
    $headers = "From: " .$email . "r\n" ;
    $headers .= "Reply-To: ".$email . "\n";
    $headers .= "MIME-Version: 1.0\r\n";
    $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";                   


    //put your email address here
    mail("email@yourdomain.com, $email", $subject, $body_message, $headers);
    ?>
    <!--Display a thankyou message in the callback -->
    <div id="mail_response">
    <h3>Thank you for your order&nbsp<?php echo $name ?>!</h3><br />
    <p>We will be calling to verify your order and take payment.</p><br />
    <p>Please look over your order above and call (281) 970-1200 if incorrect.</p><br />
    <h5>Message sent on: </h5>
    <p><?php echo $todayis ?></p>
    </div>