如何从HTML数组中获取文本区域的值

How Get value of textarea from a HTML Array

本文关键字:取文本 区域 获取 HTML 数组      更新时间:2023-09-26

我正在尝试获取下面显示的html表单的数组的值,并使用php进行显示。但我的代码似乎有问题。
请提供帮助。

html数组

<textarea   rows="1"  maxlenth = "20" class="round"    id="quantityid[]" name="quantityname[]"><?php echo $itemsale["quantity"]; ?></textarea>
<td align="center"><?php echo '<span class="remove-itm"><a href="add_sales.php?saveep='.$itemsale["productname"].'&return_url='.'add_sales.php'.'"><img src="images/saveicon.png" width="30" height="30" /></a></span>'; ?></td>
<textarea   rows="1"  maxlenth = "20" class="round"    id="quantityid[]" name="quantityname[]"><?php echo $itemsale["quantity"]; ?></textarea>
<td align="center"><?php echo '<span class="remove-itm"><a href="add_sales.php?saveep='.$itemsale["productname"].'&return_url='.'add_sales.php'.'"><img src="images/saveicon.png" width="30" height="30" /></a></span>'; ?></td>
<textarea   rows="1"  maxlenth = "20" class="round"    id="quantityid[]" name="quantityname[]"><?php echo $itemsale["quantity"]; ?></textarea>
<td align="center"><?php echo '<span class="remove-itm"><a href="add_sales.php?saveep='.$itemsale["productname"].'&return_url='.'add_sales.php'.'"><img src="images/saveicon.png" width="30" height="30" /></a></span>'; ?></td>

我的php代码

if(isset($_GET["saveep"]) && isset($_GET["return_url"]) && isset($_SESSION["cart_sales"]))
{
    $product_code   = $_GET["saveep"]; //get the product code to remove
    $return_url     = base64_decode($_GET["return_url"]); //get return url
    foreach( $_POST['quantityname'] as $v ) {
     echo $v;
    }
}

表单中的每个元素都必须具有唯一的name属性。

除非您将数据处理到客户端以发送数组,否则您将无法使用$_POST['quantityname']检索数组。

很可能只发送一个字段。

检查这个问题,找到解决你问题的好办法。