[BangPypers] two dropdowns dependents on each other

Amit Sethi amit.pureenergy at gmail.com
Tue Aug 16 12:15:33 CEST 2011


[..]
> without ajax:
>
> 1. override __init__ on your modelform, pass the value of the first
> dropdown to __init__ and populate the second dropdown depending on that
> value. If the value is None, the second dropdown will not be populated.
>
> 2. in your template, refresh the page when the value of the first
> dropdown changes.
>
There might be a small problem doing this without ajax. While
reloading, the __init__ of the first form will also  run which will
bring all user input to default,and thus would require you set the
values again explicitly instead why not get the values  as json object
and populate as required using jquery.
-- 
A-M-I-T S|S


More information about the BangPypers mailing list