On Sunday, 28 April 2013 11:21:55 UTC-3, Jorge Toro wrote:

> 2013/4/25 Tomas Schertel <tsch...@gmail.com <javascript:>>
>
>>
>>
>> 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 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 webpy+un...@googlegroups.com <javascript:>.
>> To post to this group, send email to we...@googlegroups.com <javascript:>
>> .
>> Visit this group at http://groups.google.com/group/webpy?hl=en.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>  
>>  
>>
>
>
> I think this can help you: 
> http://jolthgs.wordpress.com/2012/07/28/listas-desplegables-encadenadas-con-ajax-en-jquery/
>
>
Nice example Jorge.
I'll try this :)

-- 
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 webpy+unsubscr...@googlegroups.com.
To post to this group, send email to webpy@googlegroups.com.
Visit this group at http://groups.google.com/group/webpy?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to