zjm1126 zjm1126 - 23 days ago 7
Python Question

How to get checkbox data using python on gae

This is my HTML:

<div id='automail'>
<form action = "/admin/mail" method = "get">
auto mail when user :<br/><br/>
<div>
<input type="checkbox" name="automail" value ="signup">signUp</input><br/>
<input type="checkbox" name="automail" value ="login">login</input><br/>
</div>
<div style="text-align:right">
<input type="submit" value="save"></input>
</div>

</form>
</div>


And this is my python handle:

class mail(BaseRequestHandler):
def get(self):
all=self.request.get('automail')
if not all:
self.response.out.write('sss')
return
self.response.out.write(all)


when I choosee 'signup' and 'login', it only show 'signup'.

So how to get all data from checkbox using python on gae?

updated:

it is ok now ,two ways :

1.
all=self.request.get_all('automail')


2.
all=self.request.get('automail',allow_multiple=True)

Answer Source

If multiple arguments have the same name, self.request.get returns the first one.

You want get_all.