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

334
Views
jquery: obtenga un valor en el botón de opción de mezcla

¿Le gustaría verificar qué está mal en mi código? Tengo un botón de opción de 2 grupos cuando hago clic en la variable del botón de opción r que no tiene un valor:

 <script> $(document).ready(function() { var s = 0; var l = 0; var r = 0; $('input[type=radio][name="saverity"]').change(function() { s = $(this).val(); console.log(s); }); $('input[type=radio][name="likehood"]').change(function() { l = $(this).val(); console.log(l); }); r = s * l; console.log(r); });

Muchísimas gracias.

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

0

Algo como esto debería funcionar.

 $(document).ready(function() { var s = 0; var l = 0; var r = 0; $('input[type=radio][name="saverity"]').change(function() { s = $(this).val(); recalculate(); }); $('input[type=radio][name="likehood"]').change(function() { l = $(this).val(); recalculate(); }); function recalculate(){ r = s * l; console.log(r); } });
 <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <label> Saverity <input type="radio" name="saverity" value="0"> <input type="radio" name="saverity" value="1"> </label> <br> <label> Likehood <input type="radio" name="likehood" value="0"> <input type="radio" name="likehood" value="1"> </label>

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!