我有一個(gè)表單,一旦從主下拉列表中進(jìn)行選擇,它就會(huì)分成兩個(gè)不同的下拉列表。問(wèn)題是,當(dāng)我提交表單時(shí),我需要從每個(gè)子下拉列表中進(jìn)行選擇才能提交表單。如果未使用該變量,我該如何讓 PHP 代碼忽略該變量?例如,我希望能夠選擇“擊劍”>“colorbond”。但我還需要從內(nèi)部民事>任何中進(jìn)行選擇。為了能夠提交表單。<?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'); }});
PHP 表單有兩個(gè)下拉菜單未發(fā)送
叮當(dāng)貓咪
2023-07-08 20:29:58