Time Converter
Refer to the below image.
https://assets.ccbp.in/frontend/content/dynamic-webapps/time-converter-output.gif
Instructions:
Quick Tip
Note
Use this Background image:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>TIME CONVERTER</title>
<style>
body {
color: #f5f7fa;
font-family: sans-serif;
}
h1 {
color: #f5f7fa;
}
</style>
</head>
<body>
<style>
body {
background-image: url('https://assets.ccbp.in/frontend/dynamic-webapps/time-converter-bg.png');
}
</style>
<h1>TIME CONVERTER</h1>
<p>Enter Hours and Minutes values to convert into seconds</p>
<br>
<label for="hoursInput">Hours*</label>
<div>
<input type="number" name="hours" id="hoursInput">
</div>
<br>
<label for="minutesInput">Minutes*</label>
<div>
<input type="number" name="min" id="minutesInput">
</div>
<br>
<button type="submit" id="convertBtn" onclick="convertToSeconds(hoursInput,minutesInput)">Convert to Seconds</button><p>
<center>
<p id="convertBtn"></p>
</center>
<script>
function convertToSeconds(hours, minutes){
var hours = document.getElementById("hoursInput").value;
var minutes = +document.getElementById("minutesInput").value;
var totalsec;
totalsec = ((hours) * 60 + minutes) * 60
document.getElementById("convertBtn").innerHTML = totalsec + " seconds"
}
</script>
</body>
</html>
Comments
Leave a comment