HTML Form/Page and Navigation with multiple buttons

Paul Boddie paul at boddie.org.uk
Thu May 31 09:52:56 EDT 2007


On 31 May, 15:22, mosscliffe <mcl.off... at googlemail.com> wrote:
>

[Multiple submit buttons in HTML forms]

> How can I identify which button has been pressed.  Do I need a
> separate form for each button and hide all the relevant session fields
> in each form or is there a way of identifying which button has been
> pressed on the page.

When you define the buttons like this...

  <input name="new" type="submit" value="New search" />
  <input name="start" type="submit" value="Start" />
  <input name="previous" type="submit" value="Previous" />
  <input name="next" type="submit" value="Next" />
  <input name="last" type="submit" value="Last" />

When the user selects one of the buttons, you should get an entry for
the field representing the button in the FieldStorage object. So, if
the user presses the "next" button, there should be an entry mapping
that name ("next") to some value ("Next" in the above example) in the
FieldStorage object.

Paul




More information about the Python-list mailing list