Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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)

like image 232
zjm1126 Avatar asked Dec 06 '25 00:12

zjm1126


1 Answers

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

You want get_all.

like image 132
Drew Sears Avatar answered Dec 07 '25 17:12

Drew Sears



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!