17 lines
896 B
JavaScript
17 lines
896 B
JavaScript
function calculateCost() {
|
|
const memory = parseInt(document.getElementById('memory').value) * 5;
|
|
const vcpus = parseInt(document.getElementById('vcpus').value) * 8;
|
|
const publicIp = parseInt(document.getElementById('public-ip').value);
|
|
const storageType = parseFloat(document.getElementById('storage-type').value);
|
|
const storageSize = parseInt(document.getElementById('storage-size').value);
|
|
const storageCost = storageType * storageSize;
|
|
const networkSpeed = parseInt(document.getElementById('network-speed').value);
|
|
const os = document.getElementById('os').value;
|
|
const windowsFee = os.includes('Windows') ? 10 : 0;
|
|
const setupFee = 3;
|
|
|
|
const totalCost = memory + vcpus + publicIp + storageCost + networkSpeed + windowsFee + setupFee;
|
|
|
|
document.getElementById('total-cost').innerText = `Total Cost: ${totalCost.toFixed(2)}€`;
|
|
}
|