# VA to Watts Calculator Using JavaScript HTML With Example

Hello Friends Today, through this tutorial, I will tell you How to Write Program VA to Watts Calculator using PHP with HTML? Sure! Below is a simple HTML file containing a JavaScript function to calculate watts from volts and amperes:

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 Watts Calculator</title></head><body><h2>VA to Watts Calculator</h2><p>Enter Voltage (V): <input type="number" id="voltage"></p><p>Enter Current (A): <input type="number" id="current"></p><button onclick="calculateWatts()">Calculate</button><p>Result: <span id="result"></span> Watts</p><script>function calculateWatts() {var voltage = parseFloat(document.getElementById('voltage').value);var current = parseFloat(document.getElementById('current').value); if (isNaN(voltage) || isNaN(current)) {alert("Please enter valid numbers for voltage and current.");return;} var watts = voltage * current;document.getElementById('result').textContent = watts.toFixed(2);}</script></body></html>`

This HTML file contains a simple form with input fields for voltage and current, and a button to trigger the calculation. When the button is clicked, the `calculateWatts()` JavaScript function is called, which retrieves the values from the input fields, performs the calculation, and displays the result.

## VA to Watts Calculator

Enter Voltage (V):

Enter Current (A):

Result: Watts