(perl,html)用一个提交按钮更改两个表单值?

时间:2013-01-03 22:48:47

标签: html forms perl

我正在处理的应用程序使用变量$ mode和$ action进行导航。例如:

$mode = param('mode');
$action = param('action');

if ($mode eq 'mode1') {
  if ($action eq 'savedata') {
    &savedata();
  } elsif ($action eq 'showform') {
    &showform(); 
  }
}

通常,我只需要更改动作参数,我可以使用按钮进行操作。

$button1 = "<button type='submit' id='saveBenefit' style=\"$button_style\" name='action' class='button1' value='save'>Save</>";
$button2 = "<button type='submit' id='processBenefit' style=\"$button_style\" name='action' class='button1' value='process'>Save And Process</>";

可是:

当我点击button1时,我希望'mode'参数保持为有益,'action'参数为'save'。 当我点击button2时,我希望模式参数为'transaction','action param为'process'。

如何根据点击的按钮更改多个表单值(操作和模式)?

1 个答案:

答案 0 :(得分:0)

不能不使用某些客户端脚本。但这很愚蠢。只需在按钮的值中包含足够的信息。您甚至不需要对表单进行任何更改:

$mode = 'transaction' if $action eq 'process';