1
Hi, I’m 3 input
who receive hours and minutes of a timepicker
:
<input type="text" id="seg1" onBlur="calcular">
<input type="text" id="seg2" onBlur="calcular">
<input type="text" id="seg">
The first receives (08:30), the second receives (10:30) and the third returns (02:00).
I use the function below for full numbers in real time:
function calcular(){
var segent = parseInt(document.getElementById('segent').value, 10);
var segsai = parseInt(document.getElementById('segsai').value, 10);
document.getElementById('resultseg').value = segent - segsai;
}
However I am not able to make a small (nor large) code that works to return the value (02:00) in hours and minutes in real time.
how to avoid an:an at the time of filling in the fields?
– ThiagoKoller
@Thiagokoller I edited to contemplate this case.
– Sergio
I thought I could handle the rest myself.. the deal is that I have 4 input, I need it to calculate the first two if 3 and 4 are not filled in, if they are all (seg2 - seg1) + (seg4 - seg3).. Voce can answer here or I need to open another question?
– ThiagoKoller
@Thiagokoller how does HTML and Javascript look in this case? Put a jsFiddle here for example or join the question
– Sergio