I have just worked through it myself.
My solution is below - I did a small test app to sort it.
I am sure there are more elegant ways to solve it but this worked for me.
*Model*
db.define_table('additup',
Field('number1','integer', default = 0),
Field('number2','integer',default = 0),
Field('number3','integer', default = 0),
Field('total','integer'))
*Controller*
def index():
form = SQLFORM(db.additup)
return locals()
*View*
{{extend 'layout.html'}}
{{=form}}
<script>
jQuery("input[name='number1'],input[name='number2'],input[name='number2']").change(function()
{
jQuery("input[name='total']").val(parseInt(jQuery("input[name='number1']").val())+parseInt(jQuery("input[name='number2']").val())+parseInt(jQuery("input[name='number3']").val()));
});
</script>
On Saturday, April 21, 2018 at 7:35:22 AM UTC+12, Ayron Rangel wrote:
>
>
> I am developing an Inventory Control and am having difficulty calculating
> the sum of the values of a given product type and calculating the
> quantity of products with the same model
>
--
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 [email protected].
For more options, visit https://groups.google.com/d/optout.