This seems to work:
def absent_form():
header=['roll', 'name', 'absent']
data=[['1', 'aaaa'], ['2', 'bbbb'], ['3', 'cccc'], ['4', 'dddd']]
head=THEAD(TR( *[TH(x) for x in header[:-1]] + \
[TH((DIV(header[-1]), \
DIV(LABEL("(", \
INPUT(_name="absentall",_type="checkbox",_value="all")), \
"All)")))]))
body=TBODY(*[row + \
[INPUT(_name="absent",_type="checkbox",_value="%s"%row[0]) ] \
for row in data ])
f=FORM(TABLE(head,body,_border="1",_width="200"), \
INPUT(_type="submit",_value="submit"))
if request.vars.absentall:
# do something when absentall ="all" & redirect
print request.vars.absentall
if request.vars.absent:
# request.vars.absent can be a single value
# or a list, process & redirect
print request.vars.absent
return dict(f=f)
You are going to need a cancel button to leave the form without any
input.
On Feb 11, 10:48 pm, Rupesh Pradhan <[email protected]> wrote:
> I want using the data below, generate a table:
>
> header=['roll', 'name', 'absent']
>
> data=[['1', 'aaaa'], ['2', 'bbbb'], ['3', 'cccc'], ['4', 'dddd']]
>
> <table width="200" border="1">
> <tr>
> <th scope="col">Roll</th>
> <th scope="col">Name</th>
> <th scope="col"><p>Absent</p>
> <p>
> <label>(
> <input type="checkbox" name="absentall" id="absentall" />
> </label>
> All)</p></th>
> </tr>
> <form id="form1" name="form1" method="post" action="">
> <tr>
> <td>1</td>
> <td>aaaa</td>
> <td>
> <input type="checkbox" name="1" id="absent" />
> </td>
> </tr>
> <tr>
> <td>2</td>
> <td>bbbb</td>
> <td><input type="checkbox" name="2" id="absent" /></td>
> </tr>
> <tr>
> <td>3</td>
> <td>cccc</td>
> <td><input type="checkbox" name="3" id="absent" /></td>
> </tr>
> <tr>
> <td>4</td>
> <td>dddd</td>
> <td><input type="checkbox" name="4" id="absent" /></td>
> </tr>
>
> </table>
> <input type="submit" name="submit" id="submit" value="Submit" />
> </form>