gpt4 book ai didi

JavaScript 用户输入文本到选项值不发送到 php

转载 作者:行者123 更新时间:2023-11-28 03:58:52 26 4
gpt4 key购买 nike

我希望用户从 iframe 中的几个不同文本框中输入项目数量,并将它们显示在parent.php 中作为一个组合选项列表,您可以在其中选择每个项目并根据需要将其删除。然后我想通过 php 将所有选项值的最终列表发送到电子邮件。在将选项值分配给 php 变量之前,我一切正常。我一直没有收到任何没有列出亲属的电子邮件。我不确定如何将选项值传递给 php。

这就是我到目前为止所得到的。

父级.php

<?php

$to = 'myemail@email.com';
$subject = 'Available Item Lists';

if(isset($_POST['submit'])){
foreach ($_POST['qlist'] as $selectList) {
echo "You have the following :" .$selectList; // Display all
selection values
$body = $selectList;
}

$headers = '$email';
$headers .= 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

mail ($to, $subject, $body, $headers);
}
?>

<form method="post" id="quote-form" name="quote-form" action="?">
<label for="items">List of items</label><br />
<div class="form-section">
<select name="qlist[]" id="qlist" multiple="multiple"></select>
<button id="deleteButton" onclick="deleteEntry(); return
false;">Delete</button>
<input type="submit" value="Send" name="submit" id="submit">
</div>

<script type="text/javascript">

function displayQuantity(noOfitems, labelVal) {
var qq = noOfitems;
var labelName = labelVal;
var quoteQuantity = document.getElementById("qlist");
var quantity = quoteQuantity.value;
quantity += labelName + ": ";
quantity += qq;
quantity += " pcs\n";
quoteQuantity.value = quantity;
var option = document.createElement("option");
option.text = quantity;
quoteQuantity.add(option);

}

function deleteEntry() {
var myList = document.getElementById('qlist');
var i;
for (i = myList.length - 1; i>=0; i--) {
if (myList.options[i].selected) {
myList.remove(i);
}
}
}
</script>

iframe.php

<div class="order-quantity">
<form name="form">
<label id="itemType">Heavy Duty Square Core Drilled</label>
<input type="number" id="total-quantity" name="quantity" />
<button type="button" id="addItem"
onclick="parent.displayQuantity(this.form.quantity.value,
getVal())">Add</button>
</form>
</div>

<script type="text/javascript">
function getVal() {
var labelVal = document.getElementById("itemType").textContent;
return labelVal;
}
</script>

最佳答案

来自

 foreach ($_POST['qlist'] as $selectList)   {
echo "You have the following :" .$selectList; // Display all
selection values
$body = $selectList;
}

$Data = $_POST["qlist"];
foreach ($Data as $selectList) {
echo "You have the following :" .$selectList; // Display all
$body = $selectList;
}

关于JavaScript 用户输入文本到选项值不发送到 php,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47325475/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com