Hi, Thanks for your replies. I actually messed with some paths in my code. So it was accessing some old code and hence the new code wasnt working. Anyhow, thank you very much for your reply mdipierro. I'm able to solve my problem. :)
regards, Nithin Kumar M. On Tue, Apr 28, 2009 at 11:29 AM, newbie <mara.ku...@gmail.com> wrote: > > 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. > > On Apr 26, 3:58 am, 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 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 > > > > 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 -~----------~----~----~----~------~----~------~--~---