如何将按钮值发布到 PHP? [英] How do I post button value to PHP?

查看:25
本文介绍了如何将按钮值发布到 PHP?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在如下所示的 html 页面上使用 A-Z 按钮(只有示例和几个字)

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">

当我点击每个按钮时,我想将按钮上的相应值发布到 PHP 变量中.

when I click on each button I want to post respective values on button to a PHP variable.

我该怎么做?

推荐答案

type 更改为 submit 并给它一个 name(和删除无用的 onclick 并整理出 90 年代风格的大写标签/属性).

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" />
...

该值将由 $_POST['foo'] 提供(如果父

有一个 method="post"代码>).

The value will be available by $_POST['foo'] (if the parent <form> has a method="post").

这篇关于如何将按钮值发布到 PHP?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆