I am using web.py framework for creating small web pages.I had a basic html
that has a form with four checkbox fields as below
**home.html**
$def with ( )
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>Home</title>
</head>
<body>
<form method="POST" action="/checkboxes">
<p>check_1 <input type="checkbox" id="curly_1" value=""
name="curly_1"/></p>
<p>check_2 <input type="checkbox" id="curly_2" value=""
name="curly_2"/></p>
<p>check_3 <input type="checkbox" id="curly_3" value=""
name="curly_3"/></p>
<p>check_4 <input type="checkbox" id="curly_4" value=""
name="curly_4"/></p>
<button id="submit" name="submit">Submit</button>
</form>
</body>
</html>
**index.py**
import os
import sys
import web
from web import form
render = web.template.render('templates/')
urls = (
'/checkboxes', 'Checkboxes',
)
app = web.application(urls, globals())
class Checkboxes:
def POST(self):
i = web.input(groups = {})
print i,">>>>>>>>>>>>"
raise web.seeother('/checkboxes')
if __name__ == "__main__":
web.internalerror = web.debugerror
app.run()
**Result:**
<Storage {'curly_3': u'', 'submit': u'', 'curly_4': u'', 'curly_1':
u'', 'groups': [], 'curly_2': u''}> >>>>>>>>>>>>
So from the html view i can see four `checkbox` fields, i had checked all
checkboxes and clicked the submit button, now it should come to
`Checkboxes` class and should print the result of the input(checkboxes that
are checked) in post method as i had shown above.
But in result i am getting empty string(No result) as shown above,
can anyone please let me know whats wrong in the above code
Also how to get the values of checkboxes that are selected ?
--
You received this message because you are subscribed to the Google Groups
"web.py" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/webpy/-/oUhrGUuPtiIJ.
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.