I am a novie in coding. Please help me out.
How to create a drop down form that shows the user the data specific to a
record?
For example, in this code I have the data stored for a number of cricket
players. In this drop down list, I want to just show the data specific to
the player chosen from the drop down menu.
db.define_table ('Cricket',
Field
<http://127.0.0.1:8000/examples/global/vars/Field>('Name'),
Field
<http://127.0.0.1:8000/examples/global/vars/Field>('Age'),
Field
<http://127.0.0.1:8000/examples/global/vars/Field>('ODI_Runs'),
Field
<http://127.0.0.1:8000/examples/global/vars/Field>('ODI_Wickets')
)
db.Cricket.Name.requires = IS_NOT_EMPTY
<http://127.0.0.1:8000/examples/global/vars/IS_NOT_EMPTY> ()
db.Cricket.Age.requires = IS_INT_IN_RANGE
<http://127.0.0.1:8000/examples/global/vars/IS_INT_IN_RANGE> (0,100)
db.Cricket.ODI_Runs.requires = IS_INT_IN_RANGE
<http://127.0.0.1:8000/examples/global/vars/IS_INT_IN_RANGE> (0,20000)
db.Cricket.ODI_Wickets.requires = IS_INT_IN_RANGE
<http://127.0.0.1:8000/examples/global/vars/IS_INT_IN_RANGE> (0,1000)
def index(): return dict(message="hello from view_data.py")
def view_data() :
form=SQLFORM
<http://127.0.0.1:8000/examples/global/vars/SQLFORM>.factory(Field
<http://127.0.0.1:8000/examples/global/vars/Field>('Name',requires=IS_IN_DB
<http://127.0.0.1:8000/examples/global/vars/IS_IN_DB>(db,'Cricket.Name')))
if form.accepted:
response
<http://127.0.0.1:8000/examples/global/vars/response>.flash='Viewing Selected
Data'
records=SQLTABLE
<http://127.0.0.1:8000/examples/global/vars/SQLTABLE>(db().select(db.Cricket.ALL))
// This is the part where the problem lies. I don't know how to pass the
'Name' that has been selected.
return dict(form=form, record=records)
response <http://127.0.0.1:8000/examples/global/vars/response>.menu=[['View
Player Data', False, URL
<http://127.0.0.1:8000/examples/global/vars/URL>(view_data)]]
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.