is it possible to have two submit button for one form?
html, python, web2py
Solution
Something like this:
def search():
form = FORM(INPUT(_type='text', _name='keywords'),
INPUT(_type='submit', _value='Search'),
INPUT(_type='submit', _value="I'm feeling lucky", _name='lucky'),
_method='get')
if request.vars.keywords:
if request.vars.lucky:
[code to return "I'm feeling lucky" results]
else:
[code to return regular results]
return dict(form=form)
Giving a name to the "I'm feeling lucky" submit button causes its value to be submitted with the form, so you can check for its presence among the submitted variables and conditionally return a different response in that case.
Note, the `FORM()` helper defaults to using the post method, but because this is a search form, the above uses the get method.
You could also build the form manually in the view rather than using the `FORM()` helper.
Problem
I am using web2py to write a search engine like app. Is it possible to implement two submit button for one form such as google has two buttons "search" and "I am feeling lucky". Thanks in advance.