newbie question: form with multiple submit buttons

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

newbie question: form with multiple submit buttons

Stefaan Himpe

Hello list,

Can anyone shine some light on handling a single
form with multiple submit buttons? Can I somehow distinguish between
the different buttons in my python script?

Best regards,
Stefaan.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups-beta.google.com/group/cherrypy-users
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: newbie question: form with multiple submit buttons

Tim Roberts

stefaan wrote:

>Hello list,
>
>Can anyone shine some light on handling a single
>form with multiple submit buttons? Can I somehow distinguish between
>the different buttons in my python script?
>  
>

Absolutely.  Submit buttons have names, just like regular buttons, and
their value appears in the post data.

<form action="formHandler" method=POST>
  <input type=submit name=Button value="Buy one">
  <input type=submit name=Button value="Buy all">

    def formHandler( self, Button=None ):
        if Button=="Buy one":
        ...

--
Tim Roberts, [hidden email]
Providenza & Boekelheide, Inc.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups-beta.google.com/group/cherrypy-users
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: newbie question: form with multiple submit buttons

Sylvain Hellegouarch


>
> stefaan wrote:
>
>>Hello list,
>>
>>Can anyone shine some light on handling a single
>>form with multiple submit buttons? Can I somehow distinguish between
>>the different buttons in my python script?
>>
>>
>
> Absolutely.  Submit buttons have names, just like regular buttons, and
> their value appears in the post data.
>
> <form action="formHandler" method=POST>
>   <input type=submit name=Button value="Buy one">
>   <input type=submit name=Button value="Buy all">
>
>     def formHandler( self, Button=None ):
>         if Button=="Buy one":
>         ...
>

Indeed.

Another way if you are into Ajax would be to use Javascript to connect one
function per button onclick signal and call different URI from each
function.

- Sylvain

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups-beta.google.com/group/cherrypy-users
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: newbie question: form with multiple submit buttons

Stefaan Himpe
In reply to this post by Stefaan Himpe

Thanks a lot!

Best regards,
Stefaan.




--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups-beta.google.com/group/cherrypy-users
-~----------~----~----~----~------~----~------~--~---