hi, is it possible to add the session value to an existing session? let say i have the session purchase_order that store quantity, user can input price in form field, i want to store it in session then calculate it. e.g. *views/**transaction/**purchase_order.html* {{price = 5}} {{grand_total = 0 }}
<table class="table table-condensed table-hover"> <tr> <th>{{=T('Name') }}</th> <th>{{=T('Quantity') }}</th> <th>{{=T('Price') }}</th> <th>{{=T('Amount') }}</th> <th>{{=T('Action') }}</td> </tr> {{for id, qty in order.items():}} {{p = db.product(id) }} {{total_price = qty * price}} {{grand_total += total_price}} <tr> <td>{{=SPAN(p.name) }}</td> <td> <form> <input name="{{='quantity_%s' % p.id}}" value="{{=qty}}" class="span1" onkeyup="ajax('{{=URL('purchase_order_callback', vars = dict(id = p.id, action = 'adjust_total_price') ) }}', ['{{='quantity_%s' % p.id}}'], ':eval' )" /> </form> </td> <td> <form> <input name="{{='price_%s' % p.id}}" value="{{=price}}" class="span1" onkeyup="ajax('{{=URL('purchase_order_callback', vars = dict(id = p.id, action = 'adjust_total_price') ) }}', ['{{='price_%s' % p.id}}'], ':eval' )" /> </form> </td> <td> Rp. {{=SPAN('%s' % format(total_price, ",d"), _id = 'total_price_%s' % p.id) }} </td> <td> {{=SPAN(A(I(_class='icon-remove-sign'), callback=URL('purchase_order_callback', vars=dict(id=p.id, action='remove') ), delete='tr', _title='Remove from Order') ) }} </td> </tr> {{pass}} <tr> <td colspan=3></td> <td>{{=B(T('Grand Total') ) }}</td> <td>Rp. {{=SPAN('%s' % format(grand_total, ",d"), _id = 'grand_total') }}</td> <td></td> </tr> </table> {{=response.toolbar() }} *controllers/transaction.py* def purchase_order_callback(): id = int(request.vars.id) if request.vars.action == 'adjust_total_price': quantity = int(request.vars['quantity_%s' % id]) price = int(request.vars['price_%s' % id]) session.purchase_order[id] = quantity session.purchase_order[id] = price total_price = quantity * price grand_total = 0 for calculation_id, calculation_quantity, calculation_price in session_purchase_order.items(): product = db.product(calculation_id) calculation_total_price = calculation_quantity * calculation_price grand_total += calculation_total_price return "jQuery('#total_price_%s').html(%s);jQuery('#grand_total').html(%s);" % (str(id), str(total_price), str(grand_total) ) *response.toolbar : session* purchase_order:1:2 i've analyze with response.toolbar and got only 1 session store which is the quantity, i expect to have 2 (quantity and the price base on user input form field). how can achieve it? thanks and best regards, stifan -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.