如何将按钮值发布到PHP? [英] How do I post button value to PHP?
本文介绍了如何将按钮值发布到PHP?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在一个html页面上使用AZ按钮,如下图所示(仅适用于样本和几个字)
< INPUT TYPE =BUTTONVALUE =AONCLICK =A>
< INPUT TYPE =BUTTONVALUE =BONCLICK =B>
< INPUT TYPE =BUTTONVALUE =EONCLICK =E>
< INPUT TYPE =BUTTONVALUE =FONCLICK =F>
< INPUT TYPE =BUTTONVALUE =GONCLICK =G>
< INPUT TYPE =BUTTONVALUE =IONCLICK =I>
当我点击每个按钮时,我想将按钮上的相应值发布到PHP变量。 p>
我怎样才能做到这一点?
解决方案
更改键入
到提交
并给它一个名称
(并删除无用的 onclick
并将90年代风格的大写标签/属性展平)。
< input type =submitname =foovalue =A/>
< input type =submitname =foovalue =B/>
...
该值可由 $ _ POST ['foo']
(如果父母< form>
有一个 method =post
)。
I want use A-Z buttons on a html page like shown below (only sample and few words)
<INPUT TYPE="BUTTON" VALUE=" A " ONCLICK="A">
<INPUT TYPE="BUTTON" VALUE=" B " ONCLICK="B">
<INPUT TYPE="BUTTON" VALUE=" C " ONCLICK="C">
<INPUT TYPE="BUTTON" VALUE=" D " ONCLICK="D">
<INPUT TYPE="BUTTON" VALUE=" E " ONCLICK="E">
<INPUT TYPE="BUTTON" VALUE=" F " ONCLICK="F">
<INPUT TYPE="BUTTON" VALUE=" G " ONCLICK="G">
<INPUT TYPE="BUTTON" VALUE=" H " ONCLICK="H">
<INPUT TYPE="BUTTON" VALUE=" I " ONCLICK="I">
<INPUT TYPE="BUTTON" VALUE=" J " ONCLICK="J">
when I click on each button I want to post respective values on button to a PHP variable.
How can I do this?
解决方案
Change the type
to submit
and give it a name
(and remove the useless onclick
and flat out the 90's style uppercased tags/attributes).
<input type="submit" name="foo" value="A" />
<input type="submit" name="foo" value="B" />
...
The value will be available by $_POST['foo']
(if the parent <form>
has a method="post"
).
这篇关于如何将按钮值发布到PHP?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文