I think I've messed it up. I would like to explain my problem once
again clearly.
in controllers/identity.py:
def getcities():
citystr = request.vars.values()[0]
if citystr == "Delhi":
output = "city1, city2" # list
elif citystr == "Tamil Nadu":
output = "city2, city3" # list
elif citystr == "Andhra Pradesh":
output = "city4, city5. city6" # list
else:
output = "Bombay"
return output
def index():
form=FORM(TABLE(
TR("State:", SELECT("Andhra
Pradesh","Delhi","Tamil Nadu",_name="States",
_id="States",default="Andhra Pradesh",_onchange="ajax('/Test/default/
getcities',['States'],'handle')",requires=[IS_NOT_EMPTY()])),
TR(DIV(_id="handle")),
TR("District", SELECT({{=handle}}, _name="Choose",
_id="district", default="----", requires=[IS_NOT_EMPTY()]))))
return dict(form=form)
What i'm trying to do here is: I've built a form to enter the states
and based on the option selected by the user, I'm generating another
option list. So in the first options menu, the user input will be sent
to geticities() function using ajax which will return a json object
list of cities beloging to that input entry. Now when I use that list
(handle) in DIV tag, I'm able to display list. But I'm not able to use
that list to populate the options in second SELECT tag as shown above.
Its giving me an error on writing so. Had i written that code for the
form in a View using html, i wud not have faced these problems. Since
I'm using the SELECT tag here, I'm facing these problems.
> > This is how i've written a form withajaxto 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 usesajaxand calls a