PHP来处理动态多表单POST方法值 [英] PHP to process dynamic Multiple Form POST method values
问题描述
我有jQuery提交'N'个表格。现在我需要根据组件数读取 POST
值。任何人都可以提示读取所有 POST
值的代码吗?
尤其是我想阅读 approve1
, approve2
...
values
注意:当我点击提交时,所有这些不同的表单值都会提交到submit.php
页面
我的表单:
$ b
< form name =f1action =submit.phpmethod = POST>
< input type =hiddenname =approve1value =93545/>
< input type =submitvalue =Submit />
< / form>
< form name =f2action =submit.php method = POST>
< input type =hiddenname =approve2value =93545/>
< input type =submitvalue =Submit />
< / form>
.....
< input type =buttonvalue =全部提交/>
jQuery:
$(function(){
$(#submitAll)。click(function(ev){
ev.preventDefault();
var newForm = $(< form action ='submit.php'method ='POST'>< / form>);
$(form input [type ='hidden']) .each(function(i,e){
newForm.append(
$(< input type ='hidden'/>)
.attr(name,e .name)
.attr(value,e.value)
);
});
$(document.body).append(newForm);
newForm.submit();
});
});
foreach($ _ POST为$ name => $ value) code>在此示例中仅发布最后一个表单值
即批准2值
foreach($ _ POST为$ name => $ value){
//在这里您可以访问参数名称及其值
echo< ; p>名称是$ name,值是$ value< / p>;
}
I have jQuery to submit 'N' number of forms. Now I need to read the POST
values based on the number of components. Can anyone suggest code to read those all POST
values?
especially i want to read approve1
, approve2
...
values
Note: when i click submit all these different form values are submitted to submit.php page
My Form:
<form name="f1" action="submit.php" method=POST>
<input type="hidden" name="approve1" value="93545" />
<input type="submit" value="Submit/>
</form>
<form name="f2" action="submit.php" method=POST>
<input type="hidden" name="approve2" value="93545" />
<input type="submit" value="Submit/>
</form>
.....
<input type="button" value="Submit All"/>
jQuery:
$(function() {
$("#submitAll").click(function(ev) {
ev.preventDefault();
var newForm = $("<form action='submit.php' method='POST'></form>");
$("form input[type='hidden']").each(function(i, e) {
newForm.append(
$("<input type='hidden' />")
.attr("name", e.name)
.attr("value", e.value)
);
});
$(document.body).append(newForm);
newForm.submit();
});
});
foreach($_POST as $name => $value)
posts only last form value i.e approve2 value
in this example
foreach($_POST as $name => $value) {
// Here you have access to parameter names and their values
echo "<p>name is $name and value is $value</p>";
}
这篇关于PHP来处理动态多表单POST方法值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!