Javascript 发送选择表格“;“选定细节”;通过php

Javascript 发送选择表格“;“选定细节”;通过php,javascript,php,jquery,html,Javascript,Php,Jquery,Html,我创建了一个表单,其中包含一个影响另一个表单的选择下拉列表。我的意思是,第一个下拉列表中的选择会影响另一个下拉列表中的数据。我使用Json和jQuery实现了这一点 问题是我无法通过电子邮件获得宿舍的详细信息。它不起作用 json文件是: { "health":[ ["1","Biorgonomi"], ["2","Diet and Weight Loss"], ["3","Lasik"], ["4","Smoking Cessation"], ["5",

我创建了一个表单,其中包含一个影响另一个表单的选择下拉列表。我的意思是,第一个下拉列表中的选择会影响另一个下拉列表中的数据。我使用Json和jQuery实现了这一点

问题是我无法通过电子邮件获得宿舍的详细信息。它不起作用

json文件是:

{
"health":[
    ["1","Biorgonomi"],
    ["2","Diet and Weight Loss"],
    ["3","Lasik"],
    ["4","Smoking Cessation"],
    ["5","Body Lines"],
    ["6","Treatment of hemorrhoids"],
    ["7","Treatment of snoring"],
    ["8","personal trainer"],
    ["9","Gyms"],
    ["10","hearing aid"],
    ["11","Nail Fungus"],
    ["12","Pilates"]
],
"mercedes":[
    ["13","class A"],
    ["14","class B"],
    ["15","class C"],
    ["16","class E"]
],
"audi":[
    ["17","a3"],
    ["18","a4"],
    ["19","a5"],
    ["20","a6"]
],
"volswagen":[
    ["21","polo"],
    ["22","golf"],
    ["23","cady"]
]
}
jQuery文件是:

jQuery().ready(function(){
var tabMarque=[];
$.getJSON('http://thewebsite.com/wp-content/themes/Avada/js/healthandbeauty/healthandbeautydetails.json', function(data) {
    $.each(data, function(index, val) {
         tabMarque[index]=val;
    });
});

$('#Marque').change(function(event) {
    $marque=$(this).val();
    $htmlOption='<option value="0">Choix du serie</option>';
    if($marque!=0)
    {
        $.each(tabMarque[$marque], function(key, value) {
             $htmlOption+='<option value="'+value[0]+'">'+value[1]+'</option>';
        });
    }
    $('#Serie').html($htmlOption);
});
});
jQuery().ready(函数()){
var tabMarque=[];
$.getJSON('http://thewebsite.com/wp-content/themes/Avada/js/healthandbeauty/healthandbeautydetails.json,函数(数据){
$.each(数据、函数(索引、val){
tabMarque[index]=val;
});
});
$(“#标记”).change(函数(事件){
$marque=$(this.val();
$htmlOption='Choix du serie';
如果($marque!=0)
{
$.each(tabMarque[$marque],函数(键,值){
$htmlOption+=''+值[1]+'';
});
}
$('#Serie').html($htmlOption);
});
});
html表单:

<form action="http://thewebsite.com/wp-content/themes/Avada/js/healthandbeauty/js/send_to_email.php" method="get">
    <select id="Marque">
                <option value="0">CAR COMPANY</option>
                <option value="health">health</option>
                <option value="mercedes">mercedes</option>
                <option value="audi">audi</option>
                <option value="volswagen">volswagen</option>
            </select>
            <select id="Serie"></select>

<select id="Location">
                <option value="0">Your Location</option>
                <option value="Elondon">East London</option>
                <option value="nlondon">North London</option>
                <option value="wlondon">West London</option>
                <option value="slondon">South London</option>
            </select>
<input name="vemail" placeholder="Your Email" type="text" value="">
<input id="send" name="submit" type="submit" value="Send">

</form>

汽车公司
健康
梅赛德斯
奥迪
沃尔斯瓦根
你的位置
东伦敦
北伦敦
西伦敦
南伦敦
将详细信息发送到我的电子邮件的php文件:

<?php
if(isset($_POST["submit"])){
// Checking For Blank Fields..
if($_POST["Marque"]==""||$_POST["vemail"]==""||$_POST["Serie"]==""||$_POST["Location"]==""){
echo "Fill All Fields..";
}else{
// Check if the "Sender's Email" input field is filled out
$email=$_POST['vemail'];
// Sanitize E-mail Address
$email =filter_var($email, FILTER_SANITIZE_EMAIL);
// Validate E-mail Address
$email= filter_var($email, FILTER_VALIDATE_EMAIL);
if (!$email){
echo "Invalid Sender's Email";
}
else{
$subject = $_POST['Marque'];
$message = $_POST['Serie'];
$location= $_POST['Location'];
$headers = 'From:'. $email2 . "\r\n"; // Sender's Email
$headers .= 'Cc:'. $email2 . "\r\n"; // Carbon copy to Sender
// Message lines should not exceed 70 characters (PHP rule), so wrap it
$message = wordwrap($message, 70);
// Send Mail By PHP Mail Function
mail("myemail@xyz.com", $subject, $message, $headers, $location);
echo "Your mail has been sent successfuly ! Thank you for your feedback";
}
}
}
?>

一个主要问题似乎是您没有在
select
输入上设置
name
属性。我需要更改它而不是ID?您的一些代码依赖于这些ID AFAIC,所以只需添加与ID具有相同值的name属性。嘿,我做到了。它不起作用。提交表格后,我得到一个白色页面。url是…send_to_email.php?Marque=health&Serie=7&Location=Elondon&vemail=r.regev%40hotmail.com&submit=send检查错误日志以找出错误,或启用。