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
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 seems pretty sparse,
not to mention poorly organized.