我怎样才能从调用单一形式的多个动作? [英] How can I invoke multiple actions from a single form?
问题描述
我在,我有一个表单的jsp文件。它显示了大约一个账户数据结构,我们有数据。有一个按钮,从该数据结构删除数据。
I have a jsp file in which I have a form. It shows data about an "account" data structure we have. There's a button to remove the data from that data structure.
<form action="removeThisData.html" method="post">
... blah blah blah ...
<input type="submit" value="Remove"/>
</form>
现在,还有,我想成为一个可编辑的组件。基本上,我想那第三嗒嗒要变成一个日期。这就是我希望我能做到。
Now, there's a component that I want to be editable. Basically, I want that third blah to be turned into a date. Here's what I wish I could do.
<form action="removeThisData.html" method="post">
... blah blah blah ...
<input type="submit" value="Change blah to date"/>
<input type="submit" value="Remove"/>
</form>
不幸的是,刚刚按钮作用于形式的行动,这将调用映射到removeThisData.html的功能。
Unfortunately, that button just acts upon the form action, which invokes the functionality mapped to "removeThisData.html".
我怎样才能得到相同的形式两种不同的行为?是同一个表单中的多个行为甚至有可能的调用?如果不是,是有办法preserve一个范围内的所有信息,或者我必须重复数据/信息两种不同的形式?
How can I get two different behaviors from the same form? Is the invocation of multiple actions even possible within the same form? If it is not, is there a way to preserve all the information within a single scope or do I have to repeat the data/information in two different forms?
谢谢!
推荐答案
您可以重命名 removeThisData.html
,比方说,manageThisData.html
。您可以检查值
的提交对服务器端
按钮,并进行适当的行动的基础上,值,这将是一个删除
或更改等等最新
You could rename removeThisData.html
to, say, "manageThisData.html
". You can examine the "value"
of the submit
button on the server-side and perform suitable action, based on the value, which would be one of "Remove
" or "Change blah to date
".
这篇关于我怎样才能从调用单一形式的多个动作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!