hola estuve investigando y me encontré el siguiente codigo que calcula, pero arroja un resultado de pago mensual y yo quiero que de uno que diga Pago Total:
Código Javascript
:
Ver originalfunction calcul(){
var interest_rate = 0.0208;
var amount = parseInt($("#amount").attr("value"));
var months = parseInt($("#length").attr("value"));
var total_payment = calculate_pmt(interest_rate, months, amount);
$("#installment").val(Math.round(total_payment));
}
function calculate_pmt(interest, months, principal){
principal = Math.abs(principal) * -1;
return interest * principal * Math.pow((1 + interest), months) / (1 - Math.pow((1 + interest), months));
}
$(document).ready(function(){
//lets get the values from the meta loan helper;
var _loanMetaObj = window.top._loanMeta;
if(typeof(_loanMetaObj) == "undefined") {
var min = 2000;
var max = 43000;
var init_value = 10000;
var step = 100;
}else {
var min = (typeof(_loanMetaObj.currencies.COP.minAmount) == "undefined") ? 2000 : _loanMetaObj.currencies.COP.minAmount;
var max = (typeof(_loanMetaObj.currencies.COP.maxAmount) == "undefined") ? 43000 : _loanMetaObj.currencies.COP.maxAmount;
var init_value = (typeof(_loanMetaObj.currencies.COP.minAmount) == "undefined") ? min : 10000;
var step = (typeof(_loanMetaObj.currencies.COP.stepAmount) == "undefined") ? 100 : _loanMetaObj.currencies.COP.stepAmount;
}
$("#amountslider").slider({
value: init_value,
min: min,
max: max,
step: step,
slide: function(event,ui){
$("#amount").val(ui.value);
calcul();
}
});
$("#amount").val($("#amountslider").slider("value"));
calcul();
$("#lengthslider").slider({
value: 12,
min: 3,
max: 12,
step: 1,
orientation: "horizontal",
slide: function(event,ui){
$("#length").val(ui.value);
calcul();
}
});
$("#length").val($("#lengthslider").slider("value"));
calcul();
});
yo lo he intentado de adaptar al que ya tengo pero en el value arroja la palabra NAN.
Este es el mio, sin modificaciones.
Código Javascript
:
Ver original// JavaScript Document
$(function() {
$( "#slider-range-min" ).slider({
range: "min",
value: 600000,
min: 65000,
max: 1179000,
step: 5000,
slide: function( event, ui ) {
$( "#amount, #mcredito, #mcredito2" ).val( "$" + ui.value );
}
});
$( "#amount, #mcredito, #mcredito2" ).val( "$" + $( "#slider-range-min " ).slider( "value" ) );
});
$(function() {
$( "#slider-range-min2" ).slider({
range: "min",
value: 6,
min: 1,
max: 12,
step: 2,
slide: function( event, ui ) {
$( "#tiempo, #tiempo2, #tiempo3" ).val( "" + ui.value );
}
});
$( "#tiempo, #tiempo2, #tiempo3" ).val( "" + $( "#slider-range-min2" ).slider( "value" ) );
});
$("#tiempo2").val($("#slider-range-min2").slider("value"));