VA to amps Calculator Using JavaScript HTML With Example

Hello Friends Today, through this tutorial, I will tell you How to Write Program Voltage to Amperes (VA to Amps) calculator using PHP with HTML? Sure! Below is a simple HTML and JavaScript code to create a Voltage to Amperes (VA 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>VA to Amps Calculator</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 20px;
}
label {
font-weight: bold;
}
input[type="number"] {
width: 100px;
padding: 5px;
margin-bottom: 10px;
}
button {
padding: 10px 20px;
background-color: #007bff;
color: white;
border: none;
cursor: pointer;
}
</style>
</head>
<body>
<h2>VA to Amps Calculator</h2>
<label for="voltage">Enter Voltage (V):</label>
<input type="number" id="voltage">
<br>
<label for="power">Enter Power (VA):</label>
<input type="number" id="power">
<br>
<button onclick="calculateAmps()">Calculate</button>
<p id="result"></p>
<script>
function calculateAmps() {
var voltage = parseFloat(document.getElementById("voltage").value);
var power = parseFloat(document.getElementById("power").value);
if (!isNaN(voltage) && !isNaN(power)) {
var amps = power / voltage;
document.getElementById("result").innerText = "Current (Amps): " + amps.toFixed(2);
} else {
document.getElementById("result").innerText = "Please enter valid numbers.";
}
}
</script>
</body>
</html>

This code creates a simple web page with input fields for voltage and power in VA (Volt-Amperes). When you click the “Calculate” button, it computes the current in Amperes (Amps) using the provided voltage and power values. The result is displayed below the button.

Example:-

VA to Amps Calculator