Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

134
Views
¿Cómo puedo calcular el costo total de facturación de la lista de productos usando javascript?

Así que estoy obteniendo la información en mi página JSP usando scriptlet. Necesito calcular el costo total de los productos.

 <% List<Products> listProducts = employeeService.listProducts(); for (Products product:listProducts){ %> <tr> <th><%=product.getProduct_id() %></th> <td><%=product.getName() %></td> <td>&#8377; <%=product.getPrice() %></td> <td><%=product.getCategory() %></td> <td><input type="checkbox" name="addProduct"></td> </tr> <%} %> </tbody> <tr><input type="button" value="calculate" onclick="calculate()">Calculate</tr> </table> </div> </div> <div class="form-row"> <div class="form-group col-md-6"> <label for="shippingCost">Shipping Cost</label> <input type="number" class="form-control" id="shippingCost"> </div> <div class="form-group col-md-6"> <label for="totalOrderValue">Total Order Value</label> <input type="number" class="form-control" id="totalOrderValue"> </div> </div>

¿Cómo escribo una función Javascript para lo mismo que no puedo asignar identificadores a productos individuales aquí?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Agregue la clase a product.getPrice() td. e iterar a través de tds.

JS:

 const sum = Array.from(document.querySelectorAll(".productPrice")) .map(priceBlock => priceBlock.innerHTML) .reduce(((acc, price) => acc + +price), 0); console.log(sum)
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!