hi anthony,
here is the code :
*# controller *
def order_callback():
id=int(request.vars.id)
if request.vars.action=='add':
session.order[id]=session.order.get(id, 0)+1
if request.vars.action=='sub':
session.order[id]=max(0,session.order.get(id, 0)-1)
*# if request.vars.action=='remove':*
*# session.order[id]=session.order.clear()*
* if request.vars.action=='remove':
*
* session.order[id]=session.clear()*
return str(session.order[id])
*#view order.html*
<table width="100%">
{{for id, qty in order.items():}}
{{p=db.product(id)}}
<tr>
<td>{{=p.product_name}}</td>
<td>Rp. {{=p.unit_price}}</td>
<td><span id="{{='item%s'%p.id}}">{{=qty}}</span>
{{=SPAN(A('Add', callback=URL('order_callback', vars=dict(id=p.id,
action='add')), target='item%s'%p.id, _title='Add the Order', _class='btn
btn-navbar'))}} {{=SPAN(A('Sub', callback=URL('order_callback',
vars=dict(id=p.id, action='sub')), target='item%s'%p.id, _title='Substract
the Order', _class='btn btn-navbar'))}} *{{=SPAN(A('Remove',
callback=URL('order_callback', vars=dict(id=p.id, action='remove')),
target='item%s'%p.id, _title='Remove the Order', _class='btn btn-navbar'))}}
*</td>
</tr>
{{pass}}
</table>
the code is learned from pos online store (appliance), i've tried to add
remove function so that the product that user click can be remove as well
(not just add and subtract).
if tried both session.order.clear() and session.clear() in controller but
all of it is not work.
please show me the part that i make it wrong.
thank you so much in advance before
--
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.