如何解析发布值?
我有以下代码:
<input type="checkbox" name="pay[]" value="
<?php
echo $invoiceArr[$record_count].";";
echo $TotalArr[$record_count].";";
echo $amount_dueArr[$record_count];
?>
" onClick="checkTotal()"/>
如何解析:
echo $invoiceArr[$record_count].";";
echo $TotalArr[$record_count].";";
echo $amount_dueArr[$record_count];
当使用 POST 提交表单时?
非常感谢
我怎样才能只获取一个元素
echo $amount_dueArr[$record_count];
并将其传递给:
var elements = document.getElementsByName("pay[]");
谢谢朋友
I have the following code:
<input type="checkbox" name="pay[]" value="
<?php
echo $invoiceArr[$record_count].";";
echo $TotalArr[$record_count].";";
echo $amount_dueArr[$record_count];
?>
" onClick="checkTotal()"/>
How can I parse:
echo $invoiceArr[$record_count].";";
echo $TotalArr[$record_count].";";
echo $amount_dueArr[$record_count];
When the form is being submited with POST?
Many thanks
How can I get only one element
echo $amount_dueArr[$record_count];
and pass it into :
var elements = document.getElementsByName("pay[]");
Thanks mates
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
由于您使用
pay[]
作为表单名称,我相信您尝试进行数组表单输入。要读取数组表单输入,您只需使用它的键来读取它。一点背景知识:
您可以像这样创建数组:
从上面的代码中,您将得到包含 2 个元素的数组
$data
:返回到您的问题。要解析它,您所要做的就是循环遍历它:
Since you use
pay[]
as form name, I believe you try to do arrayed form input. To read arrayed form input, you just have to read it by using it's key.A little bit of background:
You can create array like this:
From code above, you'll ended up with array
$data
with 2 element:Back to your problem. To parse it, all you have to do is, loop through it:
这看起来像是不寻常的做事方式,但你可以通过爆炸来解析它。
That looks like unusual way to do things but you can parse it by exploding.
首先,我将输入的名称更改为
name=pay
然后在 php 中您将执行以下操作:
First of all, I would change the name of the input to
name=pay
Then in php you would do the following:
对
$_GET
或$_POST
执行var_dump
,您就会看到。此外,我认为你误解了你想要做什么。
您需要三个名为
pay[]
的元素,每个元素只有您拥有的值之一Do a
var_dump
on$_GET
or on$_POST
and you'll see.Besides, I think you are mis-understanding what you try to do.
You need three elements with the name
pay[]
, and each of them will have only ONE of the values you have