hello, I would like to update the total in the view below (bottom of the
message) when the user changes quantity. The following script works fine
(fixed value)
<script>
jQuery(document).ready(function(){
$(document).ajaxStop(function(){
jQuery('#910').slideToggle();
jQuery('#910').html('25.0');
jQuery('#910').slideToggle();
return false;
});
});
</script>
but if I replace the jQuery('#910').html('25.0');
with:
ajax("{{=URL(r=request,c='downld',f='order_reload')}}",[],'910');
where:
def order_reload():
total=sum((qty*db.product(idx).price for idx,qty in
session.cart.items()),0.0)
return HTML(str(total))
then after the first increment of qty the total gets refreshed
continuously. How can I avoid this?
thank you in advance, Marco
p.s.: here is the view
{{extend 'layout.html'}}
<h1>Checkout</h1>
<h2>Cart</h2>
<table width="100%">
{{for id, qty in cart.items():}}{{p=db.product(id)}}
<tr>
<td>{{=p.name}}</td>
<td>€ {{=p.price}}</td>
<td><span class="e" id="{{='item%s'%p.id}}">{{=qty}}</span>
{{=A('add',callback=URL('cart_callback',vars=dict(id=p.id,action='add')),target='item%s'%p.id,_class='button
pill')}}{{=A('sub',callback=URL('cart_callback',vars=dict(id=p.id,action='sub')),target='item%s'%p.id,_class='button
pill')}}
</td>
</tr>
{{pass}}
<tr>
<td>Total</td>
<!-- <td>€{{=sum((qty*db.product(id).price for id, qty in
cart.items()),0.0)}}</td> -->
<td><div class="one" id="910">€ {{=sum((qty*db.product(id).price
for id, qty in cart.items()),0.0)}}</div></td>
</tr>
</table>
--
---
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.