- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
大家好,我创建的代码有问题。它是一个下拉选择依赖形式,因此当您选择某个下拉菜单时,文本框/输入会发生变化。
现在我已经让它大部分工作了,接下来我将解释这一点。我有三个文件:form.php、JavaScript 文件和formprocess.php 文件。我在 WordPress 上有这个表单,就像我说的,它大部分都可以工作。下拉选项有“新的”和“已用的”,如果您选择“已用的”,它会直接转到已用的表格,如果您选择“新的”,它会弹出另一个选项来选择租赁或购买,并且根据您选择的选项,将显示不同的表格。现在,在每个包含“USED”、“LEASED”和“PURCHASED”的 div 中,除了两个或三个不同的值之外,它们都具有相同的值。
因此,当我提交带有“已使用”选择的表单时,我会收到填写了所有字段的电子邮件,但是,当我选择租赁或购买时,有时我没有填写任何字段,有时我会填写其中一些字段当电子邮件发送时。以下是下面的文件,我祈祷有人能看到我看不到的东西。
form.php(HTML 表单)
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Offer Submission Form</title>
<link rel="stylesheet" type="text/css" href="css/mystyle.css">
<link href="https://fonts.googleapis.com/css?family=Lato" rel="stylesheet">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
<script type="text/javascript" src="js/newForm.js"></script>
</head>
<body>
<div class="form-style-10">
<div class="inner-wrap">
<form action="" method="post">
<label>Dealership Name:<em class="required-star">*</em></label><input id="dealerName" name="dealerName" type="text" placeholder="Dealership Name" style="background-color: white;"/>
<label>Which Marketing Medium?<em class="required-star">*</em></label><select id="market" type="select" name="marketing">
<option id="market1" value="Facebook">Facebook</option>
<option id="market2" value="Website Banner">Website Banner</option>
<option id="market3" value="Radio">Radio</option>
<option id="market4" value="TV">TV</option>
<option id="market5" value="Email">Email</option>
<option id="market6" value="Direct Mail">Direct Mail</option>
<option id="market7" value="All Channels">All Channels</option>
</select>
<label>Offer Type?</label><select id="newused" type="select" name="offerType">
<option id="option_1" value="New">New</option>
<option id="option_2" value="Used">Used</option>
</select>
<div id="new" style="display:none;">
<label>Type of Purchase?</label><select id="newPick" type="select" name="typeOfPurchase">
<option id="newPick_1" value="Purchased">Purchased</option>
<option id="newPick_2" value="Leased">Leased</option>
</select>
</div>
<!--This div section is for when client select puchased as their new opiton....--->
<div id="purchased" style="display:none;">
<label>Start Date:<em class="required-star">*</em></label><input id="pur_startDate" name="startDate" type="text" placeholder="01/01/2012" style="background-color: white;"/>
<label>End Date:<em class="required-star">*</em></label><input id="pur_endDate" name="endDate" type="text" placeholder="05/07/2015" style="background-color: white;"/>
<label>Year:<em class="required-star">*</em></label><input id="pur_vehicleYear" name="yearOfVehicle" type="text" placeholder="Vehicle Year" style="background-color: white;"/>
<label>Make:<em class="required-star">*</em></label><input id="pur_make" name="makeOfVehicle" type="text" placeholder="Make" style="background-color: white;"/>
<label>Model:<em class="required-star">*</em></label><input id="pur_model" name="modelOfVehicle" type="text" placeholder="Model" style="background-color: white;"/>
<label>Trim:<em class="required-star">*</em></label><input id="pur_trim" name="trimOfVehicle" type="text" placeholder="Trim of Vehicle" style="background-color: white;"/>
<label>Model #:<em class="required-star">*</em></label><input id="pur_input_5" name="modelNumber" type="text" placeholder="14325" style="background-color: white;"/>
<label>Stock #:<em class="required-star">*</em></label><input id="pur_input_5" name="stockNumber" type="text" placeholder="1234" style="background-color: white;"/>
<label>MSRP:<em class="required-star">*</em></label><input id="pur_input_5" name="msrpNumber" type="text" placeholder="15995" style="background-color: white;"/>
<label>Selling Price:<em class="required-star">*</em></label><input id="pur_input_5" name="sellingPrice" type="text" placeholder="12895" style="background-color: white;"/>
<label>Down Payment:<em class="required-star">*</em></label><input id="pur_input_5" name="downPayment" type="text" placeholder="1000" style="background-color: white;"/>
<label>$XXX/ Monthly Payment:<em class="required-star">*</em></label><input id="pur_input_5" name="monthlyPayment" type="text" placeholder="$198" style="background-color: white;"/>
<label>Last 6 of VIN:<em class="required-star">*</em></label><input id="pur_input_5" name="lastVin" type="text" placeholder="123456" style="background-color: white;"/>
<label>Rebate:</label><input id="pur_input_5" name="rebateInfo" type="text" placeholder="Rebate on Vehicle" style="background-color: white;"/>
<label>APR:<em class="required-star">*</em></label><input id="pur_input_5" name="aprAmount" type="text" placeholder="ARP on Vehicle" style="background-color: white;"/>
<label>Term:<em class="required-star">*</em></label><input id="pur_input_5" name="termOfVehicle" type="text" placeholder="Residual Payment on Vehicle" style="background-color: white;"/>
<label>Other Notes(Rebate Info, Special Details etc):</label> <textarea id="pur_textArea" name="msg" placeholder="Notes" style="background-color: white;" rows=2></textarea>
</div>
<!--This div section is for when client select leased as their new opiton....--->
<div id="leased" style="display:none;">
<label>Start Date:<em class="required-star">*</em></label><input id="lsd_startDate" name="startDate" type="text" placeholder="01/01/2012" style="background-color: white;"/>
<label>End Date:<em class="required-star">*</em></label><input id="lsd_endDate" name="endDate" type="text" placeholder="05/07/2015" style="background-color: white;"/>
<label>Year:<em class="required-star">*</em></label><input id="lsd_vehicleYear" name="yearOfVehicle" type="text" placeholder="Vehicle Year" style="background-color: white;"/>
<label>Make:<em class="required-star">*</em></label><input id="lsd_make" name="makeOfVehicle" type="text" placeholder="Make" style="background-color: white;"/>
<label>Model:<em class="required-star">*</em></label><input id="lsd_model" name="modelOfVehicle" type="text" placeholder="Model" style="background-color: white;"/>
<label>Trim:<em class="required-star">*</em></label><input id="lsd_trim" name="trimOfVehicle" type="text" placeholder="Trim of Vehicle" style="background-color: white;"/>
<label>Model #:<em class="required-star">*</em></label><input id="lsd_model#" name="modelNumber" type="text" placeholder="14325" style="background-color: white;"/>
<label>Stock #:<em class="required-star">*</em></label><input id="lsd_stock#" name="stockNumber" type="text" placeholder="1234" style="background-color: white;"/>
<label>MSRP:<em class="required-star">*</em></label><input id="lsd_msrp" name="msrpNumber" type="text" placeholder="$15,995" style="background-color: white;"/>
<label>Selling Price:<em class="required-star">*</em></label><input id="lsd_selling_price" name="sellingPrice" type="text" placeholder="12895" style="background-color: white;"/>
<label>Down Payment:<em class="required-star">*</em></label><input id="lsd_down_payment" name="downPayment" type="text" placeholder="1000" style="background-color: white;"/>
<label>$XXX/ Monthly Payment:<em class="required-star">*</em></label><input id="lsd_monthly_payment" name="monthlyPayment" type="text" placeholder="198" style="background-color: white;"/>
<label>Last 6 of VIN:<em class="required-star">*</em></label><input id="lsd_vin" name="lastVin" type="text" placeholder="123456" style="background-color: white;"/>
<label>Rebate:</label><input id="lsd_rebate" name="rebateInfo" type="text" placeholder="Rebate on Vehicle" style="background-color: white;"/>
<label>Term:<em class="required-star">*</em></label><input id="lsd_term" name="termOfVehicle" type="text" placeholder="ARP on Vehicle" style="background-color: white;"/>
<label>Residual Value:<em class="required-star">*</em></label><input id="lsd_residual_value" name="residualValue" type="text" placeholder="Residual Payment on Vehicle" style="background-color: white;"/>
<label>Miles Per Year:<em class="required-star">*</em></label><input id="lsd_miles_year" name="milesPerYear" type="text" placeholder="Residual Payment on Vehicle" style="background-color: white;"/>
<label>Other Notes(Rebate Info, Special Details etc):</label> <textarea id="lsd_textArea" name="msg" placeholder="Notes" style="background-color: white;" rows=2></textarea>
</div>
<!-- IF users picks USED it will go to this section of the form...-->
<div id="used" style="display:none;">
<label>Start Date:<em class="required-star">*</em></label><input id="fin_startDate" name="startDate" type="text" placeholder="01/01/2012" style="background-color: white;"/>
<label>End Date:<em class="required-star">*</em></label><input id="fin_endDate" name="endDate" type="text" placeholder="05/07/2015" style="background-color: white;"/>
<label>Year:<em class="required-star">*</em></label><input id="fin_vehicleYear" name="yearOfVehicle" type="text" placeholder="Vehicle Year" style="background-color: white;"/>
<label>Make:<em class="required-star">*</em></label><input id="fin_make" name="makeOfVehicle" type="text" placeholder="Make" style="background-color: white;"/>
<label>Model:<em class="required-star">*</em></label><input id="fin_model" name="modelOfVehicle" type="text" placeholder="Model" style="background-color: white;"/>
<label>Trim:</label><input id="fin_trim" name="trimOfVehicle" type="text" placeholder="Trim of Vehicle" style="background-color: white;"/>
<label>Stock #:<em class="required-star">*</em></label><input id="fin_input_5" name="stockNumber" type="text" placeholder="1234" style="background-color: white;"/>
<label>Selling Price:<em class="required-star">*</em></label><input id="fin_input_5" name="sellingPrice" type="text" placeholder="12895" style="background-color: white;"/>
<label>Down Payment:<em class="required-star">*</em></label><input id="fin_input_5" name="downPayment" type="text" placeholder="1000" style="background-color: white;"/>
<label>APR:<em class="required-star">*</em></label><input id="fin_input_5" name="aprAmount" type="text" placeholder="ARP on Vehicle" style="background-color: white;"/>
<label>Term:<em class="required-star">*</em></label><input id="used_term" name="termOfVehicle" type="text" placeholder="" style="background-color: white;"/>
<label>Other Notes(Rebate Info, Special Details etc):</label><textarea id="fin_textArea" name="msg" placeholder="Notes" style="background-color: white;" rows=2></textarea>
</div>
<div class="button-section"><br />
<input type="submit" name="submit" value="Submit Offer" />
</div>
</form>
</body>
</div>
</div>
</html>
form.js(JavaScript 文件)
$(document).ready(function() {
$select = $('#newused');
$('#newused').on('change',function(){
if($(this).val() == "New"){
if($('#new').is(":hidden")){
$('#new').show();
$('#purchased').show();
$('#leased').show();
}
else{
$('#used').hide();
}
}
if($(this).val() == "Used"){
if($('#used').is(":hidden")){
$('#used').show();
}
else{
$('#new').hide();
$('#leased').hide();
$('#purchased').hide();
}
}
});
});
$(document).ready(function() {
$select = $('#newPick');
$('#newPick').on('change',function(){
if($(this).val() == "Purchased"){
if($('#purchased').is(":hidden")){
$('#purchased').show();
}
else{
$('#leased').hide();
$('#used').hide();
}
}
if($(this).val() == "Leased"){
if($('#leased').is(":hidden")){
$('#leased').show();
}
else{
$('#purchased').hide();
$('#used').hide();
}
}
});
});
formprocess.php(PHP 文件)
<?php
//THIS SECTION IS FOR WHEN THE PURCHASED SECTION OF THE FORM IS FILLED OUT..........////
if(isset($_POST["purchasedSubmit"]))
{
// Checking For Blank Fields....
if($_POST['dealerName']=="")
{
?>
<script type="text/javascript">
alert("Please complete the text marked with an *."); //java script telling user to fill in all required fields..
</script>
<?php
}
//THIS IS THE INFO THAT WILL BE SENT TO INDIVIDUALS IN THE EMAIL SECTION BELOW AS LONG AS ALL THE REQUIRED FIELDS ARE FILLED IN.....//////
else{
$offer = $_POST['offerType'];
$typeOfPurchase = $_POST['typeOfPurchase'];
$marketing = $_POST['marketing'];
$dealerName = $_POST['dealerName'];
$startDate = $_POST['startDate'];
$endDate = $_POST['endDate'];
$vehicleYear = $_POST['yearOfVehicle'];
$vehicleMake = $_POST['makeOfVehicle'];
$vehicleModel = $_POST['modelOfVehicle'];
$vehicleTrim = $_POST['trimOfVehicle'];
$modelNumber = $_POST['modelNumber'];
$stockNumber = $_POST['stockNumber'];
$msrp = $_POST['msrpNumber'];
$sellingPrice = $_POST['sellingPrice'];
$downPayment = $_POST['downPayment'];
$monthlyPayment = $_POST['monthlyPayment'];
$lastVin = $_POST['lastVin'];
$aprAmount = $_POST['aprAmount'];
$vehicleTerm = $_POST['termOfVehicle'];
$rebate = $_POST['rebateInfo'];
$message = $_POST['msg'];
$message = wordwrap($message, 70);
$msrpAmount = number_format($msrp, 2, '.', ',')
$sellPrice = number_format($sellingPrice, 2, '.', ',')
$dwnPayment = number_format($downPayment, 2, '.', ',')
$monthPayment = number_format($monthlyPayment, 2, '.', ',')
$apr = number_format($aprAmount, 2, '.', ',')
$rebateAmount = number_format($rebate, 2, '.', ',')
$form_content =
"What Type of Offer: $offer
If your purhcase was new what was your type of purchase: $typeOfPurchase
Which Marketing Medium: $marketing
Dealership Name: $dealerName
Start Date: $startDate
End Date: $endDate
Year of Vehicle: $vehicleYear
Make of Vehicle: $vehicleMake
Model of Vehicle: $vehicleModel
Trim of Vehicle: $vehicleTrim
Model #: $modelNumber
Stock #: $stockNumber
MSRP: $msrpAmount
Vehicle Selling Price: $sellPrice
Down Payment on Vehicle: $dwnPayment
'$'XXX/ Monthly Payment: $monthPayment
Last 6 of VIN: $lastVin
Vehicle Rebate: $rebateAmount
Vehicle APR: $apr
Other Notes (Rebate Info, Special Details etc): $message";
$email_subject = "Online Offer Submission Form";
//THIS IS THE ARRAY THAT WILL HOLD EVERYONE THAT WILL GET THE EMAIL....//////
$arrEmail = array('Jonathan <myemail@myemail.com>');
foreach($arrEmail as $key => $email_to)
mail($email_to, $email_subject, $form_content);
header('http://www.directionwebsite.com');
}
}
?>
当我提交表单时,这里使用的下拉选择是我得到的结果,请记住,为了快速起见,我将任何内容粘贴到字段中,因为现在没有验证。下面的空字段在 : 分号之后没有任何内容,是不发送任何值的空字段,但是,使用使用的选择时,这些值可能不会存储任何内容。这是我遇到问题的购买和租赁的新选择。
What Type of Offer: Used
If your purhcase was new what was your type of purchase: -1
Which Marketing Medium: All_Channels
Dealership Name: duh duh duh
Start Date: 05/07/1983
End Date: 03-11-2017
Year of Vehicle: 1983
Make of Vehicle: Ford
Model of Vehicle: Ford
Trim of Vehicle: Ford
Model #:
Stock #: 12345
MSRP:$
Vehicle Selling Price:$40,000.00
Down Payment on Vehicle:$ 4,000.00
'$'XXX/ Monthly Payment:$
Last 6 of VIN:
Vehicle Rebate:$
Residual Value:$
Vehicle APR:$175.00
Miles Per Year:
Other Notes (Rebate Info, Special Details etc): fffffffffffffffffffffffffffrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
现在,当我从选择中选择新的时,会出现另一个选择下拉列表,其中有两个选择:租赁或购买,这是我从这两个选项中得到的结果。同样,下面的字段在分号之后没有任何内容:是空字段。
What Type of Offer: New
If your purhcase was new what was your type of purchase: Purchased
Which Marketing Medium: Facebook
Dealership Name: new purchased newest try
Start Date:
End Date:
Year of Vehicle:
Make of Vehicle:
Model of Vehicle:
Trim of Vehicle:
Model #:
Stock #:
MSRP:$
Vehicle Selling Price:$
Down Payment on Vehicle:$
'$'XXX/ Monthly Payment:$
Last 6 of VIN:
Vehicle Rebate:$
Residual Value:$
Vehicle APR:$
Miles Per Year:
Other Notes (Rebate Info, Special Details etc):
最佳答案
问题
由于您在同一表单中拥有多个具有相同 name
属性的输入,因此值被覆盖。
可能的解决方案
关于javascript - 表单始终无法正确提交值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45066636/
我的问题:非常具体。我正在尝试想出解析以下文本的最简单方法: ^^domain=domain_value^^version=version_value^^account_type=account_ty
好吧,这就是我的困境: 我正在为 Reddit 子版 block 开发常见问题解答机器人。我在 bool 逻辑方面遇到了麻烦,需要一双更有经验的眼睛(这是我在 Python 中的第一次冒险)。现在,该
它首先遍历所有 y 值,然后遍历所有 x 值。我需要 X 和 y 同时改变。 For x = 3 To lr + 1 For y = 2 To lr anyl.Cells(x, 1)
假设我有一个包含 2 列的 Excel 表格:单元格 A1 到 A10 中的日期和 B1 到 B10 中的值。 我想对五月日期的所有值求和。我有3种可能性: {=SUM((MONTH(A1:A10)=
如何转换 Z-score来自 Z-distribution (standard normal distribution, Gaussian distribution)到 p-value ?我还没有找到
我正在重写一些 Javascript 代码以在 Excel VBA 中工作。由于在这个网站上搜索,我已经设法翻译了几乎所有的 Javascript 代码!但是,有些代码我无法准确理解它在做什么。这是一
我遇到过包含日期格式的时间戳日期的情况。然后我想构建一个图表,显示“点击”项目的数量“每天”, //array declaration $array1 = array("Date" => 0); $a
我是scala的新手! 我的问题是,是否有包含成员的案例类 myItem:Option[String] 当我构造类时,我需要将字符串内容包装在: Option("some string") 要么 So
我正在用 PHP 创建一个登录系统。我需要用户使用他或她的用户名或电子邮件或电话号码登录然后使用密码。因为我知道在 Java 中我们会像 email==user^ username == user 这
我在 C++ 项目上使用 sqlite,但是当我在具有文本值的列上使用 WHERE 时出现问题 我创建了一个 sqlite 数据库: CREATE TABLE User( id INTEGER
当构造函数是显式时,它不用于隐式转换。在给定的代码片段中,构造函数被标记为 explicit。那为什么在 foo obj1(10.25); 情况下它可以工作,而在 foo obj2=10.25; 情况
我知道这是一个主观问题,所以如果需要关闭它,我深表歉意,但我觉得它经常出现,让我想知道是否普遍偏爱一种形式而不是另一种形式。 显然,最好的答案是“重构代码,这样你就不需要测试是否存在错误”,但有时没有
这两个 jQuery 选择器有什么区别? 以下是来自 w3schools.com 的定义: [attribute~=value] 选择器选择带有特定属性,其值包含特定字符串。 [attribute*=
为什么我们需要CSS [attribute|=value] Selector根本当 CSS3 [attribute*=value] Selector基本上完成相同的事情,浏览器兼容性几乎相似?是否存在
我正在解决 regx 问题。我已经有一个像这样的 regx [0-9]*([.][0-9]{2})。这是 amont 格式验证。现在,通过此验证,我想包括不应提供 0 金额。比如 10 是有效的,但
我正在研究计算机科学 A 考试的样题,但无法弄清楚为什么以下问题的正确答案是正确的。 考虑以下方法。 public static void mystery(List nums) { for (
好的,我正在编写一个 Perl 程序,它有一个我收集的值的哈希值(完全在一个完全独立的程序中)并提供给这个 Perl 脚本。这个散列是 (string,string) 的散列。 我想通过 3 种方式对
我有一个表数据如下,来自不同的表。仅当第三列具有值“债务”并且第一列(日期)具有最大值时,我才想从第四列中获取最大值。最终值基于 MAX(DATE) 而不是 MAX(PRICE)。所以用简单的语言来说
我有一个奇怪的情况,只有错误状态保存到数据库中。当“状态”应该为 true 时,我的查询仍然执行 false。 我有具有此功能的 Controller public function change_a
我有一个交易表(针对所需列进行了简化): id client_id value 1 1 200 2 2 150 3 1
我是一名优秀的程序员,十分优秀!