[web2py] Re: Unable to calculate values of a selected Index

2023-03-29 Thread mostwanted
Thank you On Wednesday, March 29, 2023 at 11:11:57 AM UTC+2 Leonel Câmara wrote: > That's a good solution, one has to be careful to remember that javascript > is executed in the client and python in the server so basically you should > only really use python to give javascript some initial data

[web2py] Re: Unable to calculate values of a selected Index

2023-03-29 Thread Leonel Câmara
That's a good solution, one has to be careful to remember that javascript is executed in the client and python in the server so basically you should only really use python to give javascript some initial data that it needs- A quarta-feira, 29 de março de 2023 à(s) 08:38:04 UTC+1, mostwanted esc

[web2py] Re: Unable to calculate values of a selected Index

2023-03-29 Thread mostwanted
In my head it was all supposed to work...but ultimately this worked function calculateSubtotal(input, index) { var price = parseFloat(input.value); * var quantity = parseInt(input.parentNode.nextElementSibling.innerHTML);* var subtotal = parseFloat(pric

[web2py] Re: Unable to calculate values of a selected Index

2023-03-28 Thread Leonel Câmara
Looks like you're trying to mix javascript and python code in a quite impossible way. Just pass qty instead of index to the function and use that as the quantity. A domingo, 26 de março de 2023 à(s) 15:04:29 UTC+1, mostwanted escreveu: > I want to be able to calculate subtotal by multiplying

[web2py] Re: Unable to calculate values of a selected Index

2023-03-27 Thread Peter
To be clear I didn't come up with this (see my previous post)... Based on the provided code, it seems that the quantity variable is being assigned the same value every time, which is the value of details.quantities[index] for the first item in the list. This is because the details.quantities li

[web2py] Re: Unable to calculate values of a selected Index

2023-03-27 Thread Peter
Try... Field('quantities', 'list:integer', required=True)) On Sunday, 26 March 2023 at 15:04:29 UTC+1 mostwanted wrote: > I want to be able to calculate subtotal by multiplying quantity and price > but I cant because > *var quantity = parseInt("{{=details.quantities[index]}}");* in the >