Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

187
Vistas
Calculadora de hipotecas/Cuánto puedo pedir prestado

Tengo que reparar esta calculadora de hipotecas, pero realmente no entiendo por qué no funciona el cálculo. Necesito ayuda para solucionar esto. O al menos alguien que me haga entender lo que está mal con esta función. (La calculadora tiene una entrada para el ingreso anual combinado de los solicitantes y otra entrada para el depósito. La calculadora debe mostrar los resultados del valor máximo de la propiedad y los costos mensuales estimados).

 function PMT (rate_per_period, number_of_payments, present_value, future_value, type ) { var q = Math.pow(1 + rate_per_period, number_of_payments); return (rate_per_period * (future_value + (q * present_value))) / ((-1 + q) * (1 + rate_per_period * (type))); } jQuery(document).ready(function ($) { $(".input").keyup(function () { var annualIncomeInput = 0; var depositInput = 0; var annualIncome = 0; var deposit = 0; var mortgage = 0; var propertyValue = 0; var monthlyPayments = 0; annualIncomeInput = $('#annualIncome').val(); depositInput = $('#deposit').val(); annualIncome = parseFloat(annualIncomeInput.replace(/,/g, '')); deposit = parseFloat(depositInput.replace(/,/g, '')); if (annualIncomeInput && depositInput) { if ((deposit / 0.1 - deposit) >= (annualIncome * 4.5)) { mortgage = annualIncome * 4.5; propertyValue = mortgage + deposit; } else { propertyValue = deposit / 0.1; mortgage = propertyValue - deposit; } monthlyPayments = PMT(0.0307/12, 30*12, mortgage, 0, 0).toFixed(2); } propertyValue = parseFloat(propertyValue).toLocaleString(); monthlyPayments = parseFloat(monthlyPayments).toLocaleString(); $('#totalHowMuchCanIBorrow').text('£' + propertyValue); $('#estimatedCosts').text('£' + monthlyPayments); }) })

Si necesita más detalles por favor hágamelo saber! ¡Gracias!

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Esto funciona, tal vez encuentre el error comparándolo con el suyo :) no cambió nada, solo agregó el html adecuado.

 function PMT(rate_per_period, number_of_payments, present_value, future_value, type) { var q = Math.pow(1 + rate_per_period, number_of_payments); return (rate_per_period * (future_value + (q * present_value))) / ((-1 + q) * (1 + rate_per_period * (type))); } jQuery(document).ready(function($) { //not sure how your html looks but maybe here you want $("input") and not $(".input") that selects all elements with the css class input that's maybe missing in the html $(".input").keyup(function() { var annualIncomeInput = 0; var depositInput = 0; var annualIncome = 0; var deposit = 0; var mortgage = 0; var propertyValue = 0; var monthlyPayments = 0; annualIncomeInput = $('#annualIncome').val(); depositInput = $('#deposit').val(); annualIncome = parseFloat(annualIncomeInput.replace(/,/g, '')); deposit = parseFloat(depositInput.replace(/,/g, '')); if (annualIncomeInput && depositInput) { if ((deposit / 0.1 - deposit) >= (annualIncome * 4.5)) { mortgage = annualIncome * 4.5; propertyValue = mortgage + deposit; } else { propertyValue = deposit / 0.1; mortgage = propertyValue - deposit; } monthlyPayments = PMT(0.0307 / 12, 30 * 12, mortgage, 0, 0).toFixed(2); } propertyValue = parseFloat(propertyValue).toLocaleString(); monthlyPayments = parseFloat(monthlyPayments).toLocaleString(); $('#totalHowMuchCanIBorrow').text('£' + propertyValue); $('#estimatedCosts').text('£' + monthlyPayments); }) })
 <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <input class="input" id='annualIncome' type="number"> <input class="input" id='deposit' type="number"> <div id="totalHowMuchCanIBorrow"></div> <div id="estimatedCosts"></div>

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda