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

152
Views
¿Cómo sumar el precio de los datos e insertarlo en una entrada oculta?

Estoy resumiendo el atributo de precio de datos para varios botones de opción y luego intento insertar el resultado en un campo de entrada oculto.

Puedo resumir los datos de precio dentro del span en mi HTML, pero no puedo hacer que se inserte en la entrada oculta...

¿Debo combinar ambos scripts? y si es así, ¿cómo haría esto?

Aquí está mi HTML para referencia...

 <input type="radio" style="display:none;" id="cdjs" data-price="90" value="2BA" name="prod"> <label for="cdjs"> <img src="../../images/prod1.png" style="width:42px;"> <p>Product 1</p> </label> <span id="price"></span> <input type="hidden" id="hiddenprice" name="price" value=''>

Aquí está mi script que resume el precio de los datos.

 function calcPrice() { var price = 0; $("input[type=radio][data-price]:checked").each(function(i, el) { price += +$(el).data("price"); }); $("#price").text(price); } $("input[type=radio]").on("change", calcPrice); calcPrice();

y aquí está mi script que debería insertar el resultado en la entrada oculta.

 $(function() { $('input').change(function() { var checked = $(this).find('input[type=radio]:checked'); $('#price').html(checked.data('price')); $('#hiddenprice').val(checked.data('price')); }).change(); });
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!