Wow, this works like a charm; thanks!

On 08/29/2013 05:55 AM, Dragan Espenschied wrote:
Use the <button> element and add name and value attributes.
See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button
A button can contain other HTML elements like images.

Am 28.08.2013 22:47, schrieb Steven Brown:
This is not working for me.  What am I doing wrong?  I'm ok with using an actual
button of type submit, if that's the problem, but I need a way to have the
button show one thing, like an image or text, but the value be something
different, so I can have a bunch of buttons that just say "delete," or have an
image, but have the nitty-gritty be hidden from the user.

My relevant code:
Template snippet:
<form name="modifyPrestigeEntry" method="post">
             <td><input type="image" name="submitButton"
value="delete_$entry.entry_id" src="static/trash_can.jpg" height="25"
title="Delete Prestige" alt="Delete Prestige"/>
(Many copies of this button, all with different entry_ids.  That part comes out
right.)
</form>

python code:
         vars = web.input()
         buttonID = vars.submitButton
         print buttonID
.
.
.
         elif buttonID.split('_')[0] == 'delete':
             db.delete('entries', where="member_id = " + memberID + " AND
entry_id = " + str(scrub("int", buttonID.split('_')[1])))

Clicking one of the buttons gives the error:


   <type 'exceptions.AttributeError'> at /prestigeEntryForm


     'submitButton'

Python  /usr/lib/pymodules/python2.7/web/utils.py in __getattr__, line 70
Web     POST http://SERVER IP:1234/prestigeEntryForm


     Traceback (innermost first)

   * |/usr/lib/pymodules/python2.7/web/utils.py| in |__getattr__|
     70. raise AttributeError, k ...
     ▶ Local vars <http://68.200.151.128:1234/prestigeEntryForm#>
   * |/home/steven/Dropbox/Projects/PrestigeLogger/prestigeEntryForm.py| in 
|POST|
     70. buttonID = vars.submitButton ...
     ▶ Local vars <http://68.200.151.128:1234/prestigeEntryForm#>
   * |/usr/lib/pymodules/python2.7/web/application.py| in |handle_class|
    389. return tocall(*args) ...
     ▶ Local vars <http://68.200.151.128:1234/prestigeEntryForm#>
   * |/usr/lib/pymodules/python2.7/web/application.py| in |_delegate|
    414. return handle_class(cls) ...
     ▶ Local vars <http://68.200.151.128:1234/prestigeEntryForm#>
   * |/usr/lib/pymodules/python2.7/web/application.py| in |handle|
    232. return self._delegate(fn, self.fvars, args) ...
     ▶ Local vars <http://68.200.151.128:1234/prestigeEntryForm#>
   * |/usr/lib/pymodules/python2.7/web/application.py| in |process|
    241. return self.handle() ...
     ▶ Local vars <http://68.200.151.128:1234/prestigeEntryForm#>


     Request information


       INPUT

Variable        Value
submitButton.x  
'9'
submitButton.y  
'10'


       COOKIES

No data.


       META

Variable        Value
app_stack       
[<web.application.application instance at 0x8c9b52c>]
data    
'submitButton.x=9&submitButton.y=10'
fullpath        
u'/prestigeEntryForm'
headers         
[]
home    
u'http://SERVER IP:1234'
homedomain      
u'http://SERVER IP:1234'
homepath        
u''
host    
u'SERVER IP:1234'
ip      
u'SERVER IP'
method  
u'POST'
output  
u''
path    
u'/prestigeEntryForm'
protocol        
u'http'
query   
u''
realhome        
u'http://SERVER IP:1234'
status  
'200 OK'


       ENVIRONMENT

Variable        Value
ACTUAL_SERVER_PROTOCOL  
'HTTP/1.1'
CONTENT_LENGTH  
'34'
CONTENT_TYPE    
'application/x-www-form-urlencoded'
HTTP_ACCEPT     
'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'
HTTP_ACCEPT_ENCODING    
'gzip, deflate'
HTTP_ACCEPT_LANGUAGE    
'en-US,en;q=0.5'
HTTP_CONNECTION         
'keep-alive'
HTTP_DNT        
'1'
HTTP_HOST       
'SERVER IP:1234'
HTTP_USER_AGENT         
'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:23.0) Gecko/20100101 Firefox/23.0'
PATH_INFO       
'/prestigeEntryForm'
QUERY_STRING    
''
REMOTE_ADDR     
'SERVER IP'
REMOTE_PORT     
'41306'
REQUEST_METHOD  
'POST'
SCRIPT_NAME     
''
SERVER_NAME     
'localhost'
SERVER_PORT     
'1234'
SERVER_PROTOCOL         
'HTTP/1.1'
SERVER_SOFTWARE         
'CherryPy/3.1.2 WSGI Server'
wsgi.errors     
<open file '<stderr>', mode 'w' at 0xb76ee0d0>
wsgi.input      
<web.wsgiserver.SizeCheckWrapper object at 0x8cc7a8c>
wsgi.multiprocess       
False
wsgi.multithread        
True
wsgi.run_once   
False
wsgi.url_scheme         
'http'
wsgi.version    
(1, 0)


On 06/02/2013 07:42 AM, Dragan Espenschied wrote:
This is your HTML:

<form action="submit" method="POST">
        <input type="submit" name="do" value="delete">
        <input type="submit" name="do" value="copy">
</form>

In your script you'll check the value of the "do" variable:

class submit:
     def POST(self):
         vars = web.input()
         if vars.do == "copy":
             do_that()

Am 01.06.2013 20:27, schrieb Klerik:
hi guys, is some simply example with multiple send buttons?
I still dont understeand how can I do it.

Thanks
--
Klerik

--
You received this message because you are subscribed to the Google Groups
"web.py" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to webpy+unsubscr...@googlegroups.com.
To post to this group, send email to webpy@googlegroups.com.
Visit this group at http://groups.google.com/group/webpy?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
--
You received this message because you are subscribed to the Google Groups
"web.py" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to webpy+unsubscr...@googlegroups.com.
To post to this group, send email to webpy@googlegroups.com.
Visit this group at http://groups.google.com/group/webpy.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups 
"web.py" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to webpy+unsubscr...@googlegroups.com.
To post to this group, send email to webpy@googlegroups.com.
Visit this group at http://groups.google.com/group/webpy.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to