2013-01-03 55 views
0

我正在使用的應用程序使用變量$ mode和$ action來進行導航。例如:(perl,html)用一個提交按鈕更改兩個表單值?

$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</>"; 

但是:

當我點擊按鈕1,我想「模式」參數去住的利益,而「行動」 PARAM是「拯救」。 當我點擊button2時,我希望模式參數是'transaction','action param'是'process'。

我怎樣才能改變比基於按鈕一種形式值(包括動作和模式)點擊更多?

回答

0

如果不使用某些客戶端腳本。但那會很愚蠢。只需在按鈕的值中包含足夠的信息即可。你甚至不需要做任何修改表單:

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

我有使用客戶端腳本沒有問題,但我一直沒能得到它以任何方式工作。 我會在哪裏放置該行?以除初始參數以外的任何方式分配$模式看起來相當混亂(大約有30種不同的模式)。 – Gnippots

+0

你會創建一個'onclick'處理程序來設置'mode'輸入並返回一個真正的值。 – ikegami

+0

不能再多說了。你沒有提供任何允許更深入的答案的信息,但我確實感到你的方法很混亂。 – ikegami