Volts to amps Calculator Using JavaScript HTML With Example

Hello Friends Today, through this tutorial, I will tell you How to Write Program volts to amps calculator using PHP with HTML? Sure! Here’s a simple HTML and JavaScript code to create a volts to amps calculator:

index.html

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Volts to Amps Calculator</title>
<style>
body {
font-family: Arial, sans-serif;
}
.container {
width: 300px;
margin: 0 auto;
text-align: center;
}
input[type="number"] {
width: 100%;
padding: 8px;
margin: 5px 0;
box-sizing: border-box;
}
</style>
</head>
<body>
<div class="container">
<h2>Volts to Amps Calculator</h2>
<label for="volts">Enter Volts:</label>
<input type="number" id="volts" step="any" oninput="calculateAmps()">
<br>
<label for="resistance">Enter Resistance (Ohms):</label>
<input type="number" id="resistance" step="any" oninput="calculateAmps()">
<br>
<button onclick="calculateAmps()">Calculate Amps</button>
<p id="result"></p>
</div>
<script>
function calculateAmps() {
var volts = parseFloat(document.getElementById('volts').value);
var resistance = parseFloat(document.getElementById('resistance').value);
var amps = volts / resistance;
document.getElementById('result').innerHTML = "Amps: " + amps.toFixed(2);
}
</script>
</body>
</html>

This code creates a simple web page with two input fields: one for volts and one for resistance in ohms. When you enter values into these fields and click the “Calculate Amps” button, it calculates the amperage and displays the result below the button.

Example:-

Volts to Amps Calculator