[Zope] two submit buttons/ one method
Harry Wilkinson
harryw@nipltd.com
Thu, 9 May 2002 10:55:41 +0100
On Thursday 09 May 2002 3:22 am, John Hunter wrote:
> I have a form with two submit buttons. Rather than call two different
> methods as in
>
> <form action="" method="post">
> ...
> <input type="submit" name="some_func:method" value="Button 1">
> <input type="submit" name="some_other_func:method" value="Button 2">
> </form>
>
> I would like each button to call the same function, but with a
> different value for a variable. Something like:
>
> <form action="" method="post">
> ...
> <input type="hidden" name="somevar" value="someval">
> <input type="submit" name="some_func:method" value="Button 1">
> <input type="hidden" name="somevar" value="someotherval">
> <input type="submit" name="some_func:method" value="Button 2">
> </form>
>
> But this doesn't work.
>
> Any suggestions?
> Thanks,
> John Hunter
I do this with JavaScript. Use a hidden input tag to store the variable, and
call a function (with your parameters) on the click event of your button
which sets the parameters in the request and submits the form.
It's not the greatest solution, but it works. I need to use JavaScript
anyway since my buttons aren't in the same frame as the form.
Harry