我有一个表单,一旦从主下拉列表中进行选择,它就会分成两个不同的下拉列表。问题是,当我提交表单时,我需要从每个子下拉列表中进行选择才能提交表单。如果未使用该变量,我该如何让 PHP 代码忽略该变量?
例如,我希望能够选择“击剑”>“colorbond”。
但我还需要从内部民事>任何中进行选择。为了能够提交表单。
<?php
if(isset($_POST['submit'])){
$firstName = $_POST['first-name'];
$lastName = $_POST['last-name'];
$mailFrom = $_POST['email'];
$tel = $_POST['tel'];
$streetAddress = $_POST['street-address'];
$suburb = $_POST['suburb'];
$jobType = $_POST['job-type'];
$subJobTypeCivil = $_POST['internal-civil'];
$subJobTypeFencing = $_POST['fencing-job'];
$subject = "$jobType $firstName $lastName $suburb";
echo ''.$jobType;
$approximateMeterage = $_POST['approx-meterage'];
$message = $_POST['message'];
// workout how to files to upload
////////////////
$mailTo = "name@gmail.com";
$headers = ("WEBQ $jobType $firstName $lastName $suburb");
$txt = "New ".$jobType." enquiry. \n\n"."Customer Name: ".$firstName." ".$lastName."\n"."Email: ".$mailFrom."\n"."Phone: ".$tel."\n"."Address: ".$streetAddress.", ".$suburb."\n"."Job Type: ".$jobType."\n".
"Civil Job Type: ". $subJobTypeCivil."\n"."Fencing JobType:" .
$subJobTypeFencing .
"\n"."Approximate Meterage: ".$approximateMeterage."\n\n"."Message: ".$message;
mail($mailTo, $subject, $txt, $headers);
header("Location: index.html");
}
?>
function navHamburger() {
var x = document.getElementById("nav-links");
if (x.style.display === "block") {
x.style.display = "none";
} else {
x.style.display = "block";
}
}
// CONTACT US FORM ////////////////////////////////////////////////////////////////////
$("#job-type").change(function(){
if ($(this).val() == "internals-civil") {
$('#telecom-internal-civil').show();
$('#internal-civil').attr('required', '');
$('#internal-civil').attr('data-error', 'This felid is required');
} else {
$('#telecom-internal-civil').hide();
$('#internal-civil').removeAttr('required');
$('#internal-civil').removeAttr('data-error');
}
});
慕田峪7331174