表单上的多个提交按钮 [英] Multiple Submit Buttons On Form

查看:99
本文介绍了表单上的多个提交按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
HTML表单中的多个提交按钮

Possible Duplicate:
Multiple submit buttons in an HTML form

我想知道是否有人可以帮助我.

I wonder whether someone may be able to help me please.

我整理了表格,如您所见在页面底部,允许用户添加和删除与主记录关联的图像文件.

I've put together this form which, as you can see at the bottom of the page, allows a user to add and delete image files associated with the main record.

我遇到的问题是,后面有多个按钮具有提交"操作,即:上传此文件",删除选定的图像",查看选定的图像"和提交",并且其中,与我使用的按钮无关紧要,执行的唯一操作是提交完整的记录.

The problem that I have is that there are multiple buttons that have a 'Submit' action behind them, namely: 'Upload this File', 'Delete Selected Image', 'View Selected Image', and 'Submit' and because of this, immaterial of the button I use, the only action performed is a complete record submission.

也许有人可以告诉我,我如何确保每个按钮后面的提交"动作彼此独立地起作用.

Could someone perhaps tell me please how I can make sure that the 'Submit' action behind each button works independently of each other.

非常感谢和问候

推荐答案

您无需为每个按钮使用单独的表单. 您可以在提交"按钮的名称"中使用不同的值.然后在服务器上,您可以检查"form_action"的值

You don't need to use separate form for each button. You can just use different value in the "name" of submit button's. Then on the server you can examine the value of 'form_action'

示例:

<input name="form_action[delete]" type="submit" value="Delete">
<input name="form_action[update]" type="submit" value="Update">

根据需要输入这些按钮的菜单. 在服务器上检查$ _POST ['form_action']

Put as manu of these buttons as you want. On the server examine the value of $_POST['form_action']

这篇关于表单上的多个提交按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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