Nice example of a cascaded field.

On Apr 25, 6:58 pm, mdipierro <mdipie...@cs.depaul.edu> wrote:
> Not sure I understand but you can try:
>
> def getcities():
>     citystr = request.vars.values()[0]
>     if citystr == "Delhi":
>         output = "Hyderabad"
>     elif citystr == "Tamil Nadu":
>         output = "Chennai"
>     elif citystr == "Andhra Pradesh":
>         output = "Pune"
>     else:
>         output = "mumbai"
>     return TAG[''](OPTION("----"),OPTION("asfas"),OPTION
> ("safee"),OPTION(output))
>
> def index1():
>     form=FORM(TABLE(
>                     TR("State:", SELECT("Andhra
> Pradesh","Delhi","Tamil Nadu",_name="States",
> _id="States",default="Delhi",_onchange="ajax('/Test/default/
> getcities',
> ['States'],'district')",requires=[IS_NOT_EMPTY()])),
>                     TR("District", SELECT("----","asfas","safee",
> _name="Choose", _id="district", default="----", requires=[IS_NOT_EMPTY
> ()]))))
>     return dict(form=form)
>
> On Apr 25, 3:51 pm, newbie <mara.ku...@gmail.com> wrote:
>
> > in Controller/index.py:
> > def getcities():
> >     citystr = request.vars.values()[0]
> >     if citystr == "Delhi":
> >         output = "Hyderabad"
> >     elif citystr == "Tamil Nadu":
> >         output = "Chennai"
> >     elif citystr == "Andhra Pradesh":
> >         output = "Pune"
> >     else:
> >         output = "mumbai"
> >     return output
>
> > def index1():
> >     form=FORM(TABLE(
> >                     TR("State:", SELECT("Andhra
> > Pradesh","Delhi","Tamil Nadu",_name="States",
> > _id="States",default="Delhi",_onchange="ajax('/Test/default/getcities',
> > ['States'],'handle')",requires=[IS_NOT_EMPTY()])),
> >                     TR(DIV(_id="handle")),
> >                     TR("District", SELECT("----","asfas","safee",
> > _name="Choose", _id="district", default="----", requires=[IS_NOT_EMPTY
> > ()]))))
> >     return dict(form=form)
>
> > This is how i've written a form with ajax to auto-populate SELECT
> > boxes. But in the above code, if i want to use the "handle" variable
> > and display it as an option in SELECT box, I'm not able to do that. If
> > i return a list into the "handle" variable then how do i populate the
> > list in SELECT box. Please reply me asap.
>
> > Thanks,
> > Nazgi.
>
> > On Apr 25, 2:21 pm, Nazgi <mara.ku...@gmail.com> wrote:
>
> > > Hi,
>
> > >        I hav written a form in controller of my application. The form
> > > has a select option which based on its input uses ajax and calls a
> > > function. This function sends a json list object. How do I access that
> > > variable in order to incorporate the contents of that list as another
> > > select option menu.?
>
> > > Thanks.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to