繁体   English   中英

如何从HTML数组获取textarea的值

[英]How Get value of textarea from a HTML Array

我正在尝试获取如下所示的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']检索数组。

最有可能只发送一个字段。

检查此问题 ,以解决您的问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM