+ 1

How to sum numbers in a table?

Iā€™ve created a table in HTML with <table> and now I would like to write a JS function: my goal is that the user could write any number in the first row, another number in the second and in the third the function would add the two numbers and write the sum automatically. Is it possible? Thank you for your help!

6th Aug 2020, 1:09 PM
Gabor
Gabor  - avatar
5 Answers
+ 1
It depends on how you render your table, if it's Javascript you will have an array with the content so you can use reduce and get a last value and then render as a <tfoot>
6th Aug 2020, 3:29 PM
Erick Ventura
Erick Ventura - avatar
+ 1
it's not a table but a form but as a start it's ok for me now. https://code.sololearn.com/WTL30eaR40X5/#html
8th Aug 2020, 9:36 AM
Gabor
Gabor  - avatar
0
Show your attempt first
6th Aug 2020, 1:13 PM
v@msišŸ˜‰
v@msišŸ˜‰ - avatar
0
i dont have one, just created a table with three rows and thats all. i am lost
6th Aug 2020, 1:16 PM
Gabor
Gabor  - avatar
0
Link your code that you tried
6th Aug 2020, 1:21 PM
v@msišŸ˜‰
v@msišŸ˜‰ - avatar