Something like this?

def delete_things():
    table = TABLE()
    recs = db(db.things.id > 0).select()
    for rec in recs:
        chk = INPUT(_type='checkbox',
                    _name='st_%s' % rec.id)
        table.append(TR(rec.id,rec.name,chk))
    form = FORM(table,INPUT(_type='submit'))
    if form.accepts(request.vars,session):
        for k,v in request.vars.items():
            if k.startswith('st_'):
                id = k.split('_')[-1]
                db(db.things.id == int(id)).delete()
    return dict(form=form)

On Jun 6, 6:39 pm, NetAdmin <[email protected]> wrote:
> I have a table with the following structure.
>     firstname string
>     st            boolean
>
> I can display the info with a view,
> but I'd like to check/uncheck certain names
> using the status check box, then delete
> the checked names.
>
> I feel I'm going about this the WRONG way
> because most of the logic should be in
> a controller, and views should mostly
> only display the data.
>
> Here's the view.
>
> Thanks in advance!
>
> <table>
> {{ for r in recs : }}
> <tr>
> {{=TD(r.id)}} {{=TD(r.firstname)}}
> <td><form> <input type = 'checkbox' name = 'st' {{ if r.st == True: }}
> checked {{pass}} > </form> </td>
> </tr>
> {{pass}}
> <table>

Reply via email to