You can create two actions, one to show the items and the other one to
delete them one by one via request.args[0]:
# list of items with delete link
def show_items():
rr=db(db.item.id>0).select()
return dict(items=TABLE(*[ (
TD(r.name),
TD(A('delete this
item',_href=URL(c=request.controller,f='del_item',args=[r.id])))
) for r in rr ]))
def del_item():
if request.args and request.args[0]:
item_id=request.args[0]
db(db.item.id==item_id).delete()
session.flash='item %s deleted' %item_id
else:
session.flash='item not found'
redirect(URL(c=request.controller,f='show_items'))
On Mar 10, 2:19 pm, Rick <[email protected]> wrote:
> I meant that I'd like to print on a html _page_.
>
> On Mar 10, 6:34 pm, Rick <[email protected]> wrote:
>
> > I'd like to print the list in a html file.
>
> > On Mar 10, 6:16 pm, Bruno Rocha <[email protected]> wrote:
>
> > > where do you want to output this?
>
> > > in to pure HTML or in a SQLTABLE?
>
> > > 2011/3/10 Rick <[email protected]>
>
> > > > Hi,
>
> > > > I want to print a linked list and add a "delete this item" button next
> > > > to each item:
> > > > ************
> > > > [item 1][delete this item]
> > > > [item 2][delete this item]
> > > > [item 3][delete this item]
> > > > ************
> > > > ...but I've no clue how to write the code. The problem is to direct
> > > > the second delete button to the second item.
>
> > > > Thanks in advance for help!
>
>