In index.html I've added link to redirect to search.html page.:
{{=P(A(T("Click to search the Database"),
_href=URL('myapp','default','search')),_style="padding-top:1em;")}}
When I try to go to search page I get this error:
Error traceback
Traceback (most recent call last):
File "gluon/restricted.py", line 186, in restricted
File "F:/Programy/web2py/applications/myapp/controllers/default.py",
line 69, in <module>
File "gluon/globals.py", line 96, in <lambda>
File "F:/Programy/web2py/applications/myapp/controllers/default.py",
line 57, in search
File "gluon/html.py", line 358, in __init__
SyntaxError: <input/> tags cannot have components
def search():
form=SQLFORM.factory(INPUT('no_1','integer'), <= line 57
INPUT('no_2','integer'),
INPUT('no_3','integer'),
INPUT('no_4','integer'))
if form.accepts(request.vars,keepvalues=True):
items=db(db.numbers.no_1.contains(form.vars.no_1)|\
db.numbers.no_2.contains(form.vars.no_2)|\
db.numbers.no_3.contains(form.vars.no_3)|\
db.numbers.no_4.contains(form.vars.no_4)).select()
else: items=[]
return dict(form=form,items=items)
response._vars=response._caller(search) <= line 69
On 11 Wrz, 22:16, mdipierro <[email protected]> wrote:
> I would do this:
>
> db.define_table('numbers',
> Field('nos', 'list:integer', widget=ListStringWidget),
> Field('date', 'date',default=now)
>
> where StringListWidget is defined
> here:http://groups.google.com/group/web2py/msg/0c2600730ece873a
> then
>
> def search():
> form=SQLFORM.factory(INPUT('no1','integer'),
> INPUT('no2','integer'),
> INPUT('no3','integer'),
> INPUT('no4','integer'))
> if form.accepts(request.vars,keepvalues=True)):
> items=db(db.numbers.nos.contains(form.vars.no1)|\
> db.numbers.nos.contains(form.vars.no2)|\
> db.numbers.nos.contains(form.vars.no3)|\
> db.numbers.nos.contains(form.vars.no4)).select()
> else: items=[]
> return dict(form=form,items=items)
>
> On Sep 11, 1:05 pm, elfuego1 <[email protected]> wrote:
>
> > Here are some more detailed informations you asked for:
>
> > The form has to search always for 4 numbers.
> > The result may show 4 numbers or less (when matched).
> > Position is not important.
> > Search will be always for 4 numbers.
> > All 4 fields have numbers. There are no empty fields in DB.
>
> > On 11 Wrz, 16:19, mdipierro <[email protected]> wrote:
>
> > > Will your search form accept one number or 4? Do you need to search
> > > for records that have any of the numbers of all of the numbers? Are
> > > the position (1,2,3,4) and the numbers important? Is 4 fixed or may
> > > that increase in the future? Can the value of any of the no_x fields
> > > be None or other than a number?
>
> > > On Sep 11, 12:12 am, elfuego1 <[email protected]> wrote:
>
> > > > Hello,
>
> > > > I need to create a search form.
> > > > In my DB I have fields with numbers. Now I need to look up the DB and
> > > > find out if the numbers I enter are there already or not.
>
> > > > db.define_table('numbers',
> > > > Field('no_1', length=18),
> > > > Field('no_2', length=18),
> > > > Field('no_3', length=18),
> > > > Field('no_4', length=18),
> > > > Field('date', 'date',default=now)
>
> > > > I'd like to get two kinds of information from the DB.
> > > > 1. If there is a matching record in DB:
> > > > I'd like to display all fields with matching numbers and a date
> > > > when that happend (last field in DB contains a date).
> > > > 2. If there is NO MATCH:
> > > > I'd like to get answer: „No matching record found”.
>
> > > > Can you tell me what should I do to generate a search form with four
> > > > input fields and run their contetns against my DB?
>
> > > > Best regards.
>
>