This is my template
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>My Awesome App</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" />
<link rel="stylesheet" type="text/css" href="/.css" />
<script src="/views/layouts/client.js"></script>
<script src="/server.js"></script>
</head>
<body>
}
</body>
</html>
I link the file in the head and then I call the function here
<input
id="months"
type="number"
min="1"
max="300"
value="1"
step="1"
onchange="computeLoan()"
/>
Finnaly here is my js function
function computeLoan(){
const amount = document.querySelector('#amount').value;
const interest_rate = document.querySelector('#interest_rate').value;
const months = document.querySelector('#months').value;
const interest = (amount * (interest_rate * 0.01)) / months;
let payment = ((amount / months) + interest).toFixed(2);
payment = payment.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
document.querySelector('#payment').innerHTML = `Monthly Payment = ${payment}`
}
and here is the dev tool error
Failed to load resource: the server responded with a status of 404 ()
Refused to execute script from 'https://bpa-2022-2023.glitch.me/client.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.
however, it never works I have tried console logs, those don't show up, I have also tried putting the function in my server.js thinking it might be able to run in there, no use I have even tried placing the script tags in different spots on page no luck. Nothing I have googled has worked.
Via Active questions tagged javascript - Stack Overflow https://ift.tt/fEQJCwV
Comments
Post a Comment