I trying to add the following two numbers:
hh: 1 (hours) mm: 45 (Minutes)
I want to have as decimal result the the following: 1.75
But I am getting as result: 10.75. I tried with .toFixed(2)
...
Could you please advise where I am doing the mistake?
$("#x_hh").change(function() {
var hh = parseInt($("#x_hh").val());
var mm = parseFloat($("#x_mm").val());
var dmm = parseFloat($("#x_mm").val()/60).toFixed(2);
var studmin =$("#x_hh").val()+":"+$("#x_mm").val();
$("#x_decimalstd").val(hh+dmm);
$("#x_stdmin").val(studmin);
});
The result returns
10.75
becausehh = 1
anddmm = 0.75
, and+
operator concatenates them.Try,
or