Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
forms in web2py
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  6 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Nazgi  
View profile  
 More options Apr 25, 5:21 am
From: Nazgi <mara.ku...@gmail.com>
Date: Sat, 25 Apr 2009 02:21:49 -0700 (PDT)
Local: Sat, Apr 25 2009 5:21 am
Subject: forms in web2py
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.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
newbie  
View profile  
 More options Apr 25, 4:51 pm
From: newbie <mara.ku...@gmail.com>
Date: Sat, 25 Apr 2009 13:51:08 -0700 (PDT)
Local: Sat, Apr 25 2009 4:51 pm
Subject: Re: forms in web2py
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:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
mdipierro  
View profile  
 More options Apr 25, 6:58 pm
From: mdipierro <mdipie...@cs.depaul.edu>
Date: Sat, 25 Apr 2009 15:58:27 -0700 (PDT)
Local: Sat, Apr 25 2009 6:58 pm
Subject: Re: forms in web2py
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:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
newbie  
View profile  
 More options Apr 28, 1:59 am
From: newbie <mara.ku...@gmail.com>
Date: Mon, 27 Apr 2009 22:59:01 -0700 (PDT)
Local: Tues, Apr 28 2009 1:59 am
Subject: Re: forms in web2py
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:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Nithin Kumar M  
View profile  
 More options Apr 28, 6:32 am
From: Nithin Kumar M <mara.ku...@gmail.com>
Date: Tue, 28 Apr 2009 16:02:59 +0530
Local: Tues, Apr 28 2009 6:32 am
Subject: Re: [web2py:20706] Re: forms in web2py

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.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
DenesL  
View profile  
 More options Apr 28, 11:10 am
From: DenesL <denes1...@yahoo.ca>
Date: Tue, 28 Apr 2009 08:10:07 -0700 (PDT)
Local: Tues, Apr 28 2009 11:10 am
Subject: Re: forms in web2py
Nice example of a cascaded field.

On Apr 25, 6:58 pm, mdipierro <mdipie...@cs.depaul.edu> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google