Hello Friends Today, through this tutorial, I will tell you How to Create Amps to Volts Calculator Using JavaScript with HTML? Below is an example of an Amps to Volts calculator using HTML and JavaScript:
index.html
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Amps to Volts Calculator</title> <style> body { font-family: Arial, sans-serif; margin: 20px; } label { display: block; margin-bottom: 8px; } input { width: 100%; padding: 8px; margin-bottom: 16px; box-sizing: border-box; } button { background-color: #4CAF50; color: white; padding: 10px 15px; border: none; border-radius: 4px; cursor: pointer; } button:hover { background-color: #45a049; } </style> </head> <body> <h2>Amps to Volts Calculator</h2> <label for="amps">Enter Amperage (A):</label> <input type="number" id="amps" placeholder="Enter amperage"> <label for="resistance">Enter Resistance (Ohms):</label> <input type="number" id="resistance" placeholder="Enter resistance"> <button onclick="calculateVolts()">Calculate Volts</button> <p id="result"></p> <script> function calculateVolts() { // Get the amperage input value const amps = parseFloat(document.getElementById('amps').value); // Get the resistance input value const resistance = parseFloat(document.getElementById('resistance').value); // Calculate voltage (V) const voltage = amps * resistance; // Display the result document.getElementById('result').innerHTML = `Voltage (V): ${voltage} Volts`; } </script> </body> </html>
In this calculator, users can input the amperage (A) and resistance (Ohms) values. Upon clicking the “Calculate Volts” button, the `calculateVolts()` function is triggered. This function retrieves the amperage and resistance values, performs the calculation for voltage using Ohm’s law (V = I * R), and then displays the result on the page.