2011/1/24 ilejn <[email protected]>:
> Hello!
>
> What is the best way to put two forms at one Web page?
>
> Each form is just a textbox.
>
> While GET part is more or less clear (I just pass all these forms to
> template), processing POST I have to find out which form was filled
> since it is important for business logic.
>
> My current approach is to examine web.input() content
> if 'Url1:' in web.input():
>       checkurl = str(web.input()['Url1:'])
> else:
>       checkurl = str(web.input()['Url2:'])
>
> It works, though it does not look elegant. Could someone please
> suggest anything better.
>
> Besides this, I have to use different names for my two textboxes,
> while I prefer giving the same name to them. Is it possible [assuming
> 'id' and 'label' are different at HTML level] ?

Put a hidden box in each form with different value.

def POST(self):
    i = web.input()

    # assuming that the name of the hidden field is "form"
    if i.form == "foo":
        return self.POST_foo(i)
    else:
        return self.POST_bar(i)

-- 
You received this message because you are subscribed to the Google Groups 
"web.py" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/webpy?hl=en.

Reply via email to