2015-06-29 33 views
1

讓我說我有一個文本字段的列表。每個文本字段都負責一些產品ID,我想知道應該購買多少物品。如何獲得像關聯數組的請求參數

結果的參數應該是像{ :1 => 2, :5 => 8 },這意味着用戶將購買2項產品編號1,和8項產品的ID爲5

什麼是這個預期input[type="text"] html標籤的預期name屬性案件?

+0

你能提供的平臺和語言上的一些細節你正在服務器端工作?什麼是解析請求? – vallismortis

+0

我是Rails dev。但我現在對原始html感興趣。 – asiniy

回答

0

假設您的

<input type="text" name="product<?php echo $product_id; >"></input> 

你可以使用jQuery提交值一樣

var x = $('input[name=\'product' + pid + '\']').val(); // where pid is any product_id 
服務器上

可以使用

$this->request->get['product'.$pid];//pid is any product_id 
+0

如何使用您的答案獲得關聯數組? – asiniy

相關問題