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

128
Views
Sumar dos salidas juntas

Obtuve una calculadora de ganancias de un desarrollador, que funciona perfectamente, y quiero agregar el resultado final con la cantidad que se ha ingresado.

Este es mi código:

 //////////PROFIT CALCULATOR const numbers = document.querySelectorAll(".number"); const resultText = document.querySelector(".result"); let value, percent; // must be declared outside of the foreach numbers.forEach((number) => { number.addEventListener("input", () => { if (number.classList.contains("value")) { value = parseFloat(number.value); } if (number.classList.contains("percent")) { percent = parseFloat(number.value); } if ((value || value == 0) && (percent || percent == 0)) { resultText.innerHTML = calculate(value, percent); } }); }); function calculate(val, percent) { return (val * percent) / 100; }
 <div class="percentage-calc"> <div class="input_container"> <span>Amount</span> <input type="number" class="number value">$ </div> <div class="input_container"> <span>Percent</span> <input type="number" class="number percent">% = $ <span class="result"></span> </div> </div>

por favor necesito ayuda

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Si entendí correctamente, desea agregar el resultado a la cantidad escrita.

Agregue el valor a su función de cálculo:

 function calculate(val, percent) { return (val * percent) / 100 + value; }
about 4 years ago · Santiago Trujillo 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!