簡體   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