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

149
Views
¿Cómo obtener el valor de la suma de entrada de la tabla depende del cuadro de selección?

La parte HTML del código a continuación funciona cuando lo uso sin una tabla, pero no funciona cuando las entradas del formulario se colocan dentro de la fila de la tabla. Básicamente el total será hacia abajo según la caja celeste. ¿Alguien puede ayudar por favor?

 <script> $(document).on("change", ".track,[name='type[]']", function() { const sum = { male: 0, female: 0 }; $(".track").each(function() { const type = $(this).prev().val(); sum[type] += +$(this).val(); }); $("#male-total").val(sum.male); $("#female-total").val(sum.female); }); </script>
 <script src="https://code.jquery.com/jquery-3.5.1.min.js" crossorigin="anonymous"></script> <table widht="100" border="1" > <tr> <th><select name='type[]'><option value='male'>Male</option><option value='female'>Female</option></select></th> <th><input type="text" name="amount[]" class="track" value="" /> </th> </tr> <tr> <th><select name='type[]'><option value='male'>Male</option><option value='female'>Female</option></select></th> <th><input type="text" name="amount[]" class="track" value="" /> </th> </tr> </table> <hr> <label> Male Total: </label> <input type="text" id="male-total" value="" /> <label> Female Total: </label> <input type="text" id="female-total" value="" />

about 4 years ago · Juan Pablo Isaza
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!