The first link looks pretty slick, so I'm going to use that; but how do
I give the different options a class? web.py says that each option is
created by a tuple with the id and description, but there's nothing I
can find about giving them classes. I would like to avoid adding the
class after the form is rendered if possible.
On 04/25/2013 01:04 PM, Tomas Schertel wrote:
On Wednesday, 24 April 2013 19:58:42 UTC-3, Steven Brown wrote:
I have a few questions, and I'm not even sure how to google for
them. I am writing a page with a form. The form consists of
several identical lines of fields, where the user can fill in as
many or as few lines of information as they want. So, each line
is going to have a date field, a dropdown indicating a selected
option, and a text box for some notes. Now, I'm sure I could
implement this by building the python-side form array with a loop,
where every time through the loop adds another set of fields to
the list of fields. My question is, on the HTML side, how should
I access them to render them? My first instinct is to just use an
eval statement; something like
|$:for i in range(10):
eval('form.date' + i + '.render()')
|| eval('form.choice' + i + '.render()')
|| eval('form.notes' + i + '.render()')
print '<br/ >'
|
But this seems inelegant, not least because everyone has always drilled
into me to never
use eval except in the most dire of circumstances. Is there a better way?
What would also be
good, is if there was some way I could define how to render a single line,
in another place,
and then call that process inside the for loop above.
Another thing I am trying to do in the cleanest, most efficient way
possible is change
what's in the dropdown, depending on what is selected in the date field
(and later another
dropdown). I found
this:http://stackoverflow.com/questions/8763564/how-do-i-update-a-dropdown-menu-when-another-dropdown-menu-option-is-selected
<http://stackoverflow.com/questions/8763564/how-do-i-update-a-dropdown-menu-when-another-dropdown-menu-option-is-selected>
which suggests using jQuery, but I'm wondering first, if there is any way
strictly within web.py
to do it. Second, I am going to populate the dropdown from a database, and
the only way I can
figure of doing everything, I need to a database query for every set of
options. So, am I
correct in that assumption, or is there is a way to minimize dB hits.
Finally, is there a better place to get documentation for web.py?webpy.org
<http://webpy.org> seems pretty sparse,
not to mention poorly organized.
To populate dropdown with database values, you can use a jquery plugin.
Two examples:
https://github.com/tuupola/jquery_chained
http://github.e-sites.nl/populate/
--
You received this message because you are subscribed to the Google
Groups "web.py" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/webpy?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
--
You received this message because you are subscribed to the Google Groups
"web.py" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/webpy?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.