Código HTML:
Ver original
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <script language="javascript"> function calcHr(){ var hr = parseInt(document.getElementById(hr_2)) - parseInt(document.getElementById(hr_1)); var min = parseInt(document.getElementById(min_2)) - parseInt(document.getElementById(min_1)); if(min)<0){ min = min + 60; hr = hr -1; document.getElementById(uf).value = hr.toString() + ":" + min.toString(); } else{ document.getElementById(uf).value = hr.toString() + ":" + min.toString(); } } </script> </head> <body> <form id="frm" name="frm"> <table width="350" align="center"> <tr> <input name="hr_1" type="text" id="hr_1" size="5" /> <input name="min_1" type="text" id="min_1" size="5" /> </tr> <tr> <input name="hr_2" type="text" id="hr_2" size="5" /> : </div> <input name="min_2" type="text" id="min_2" size="5" /> </tr> <tr> <input type="button" name="Submit" value="Calcular" onclick="calcHr()" /> </tr> <tr> <input name="uf" type="text" id="uf" /> </tr> </table> </form> </blockquote> </blockquote> </blockquote> </blockquote> </blockquote> </blockquote> </blockquote> </blockquote> </body> </html>