Time Converter
In this assignment, let's build a Time Converter by applying the concepts we learned till now.
Refer to the below image.
https://assets.ccbp.in/frontend/content/dynamic-webapps/time-converter-output.gif
Instructions:
By following the above instructions, achieve the given functionality.
Quick Tip
Note
Use this Background image:
CSS Colors used:
Text colors Hex code values used:
#f5f7fa
#000000
#ffffff
CSS Font families used:
<!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