This is a ion exchange calculation for softener resin linked to my job. I've run this code in Javacript and displayed it on the console but where do you begin to run that on a webpage. I know how to link a JS file using the script on a HTML page but how does the code get executed. I'm a bit confused with getELement ID or querySelectors so i was hoping to get some pointers of where i can start to look. Apologies for the ametuer question
const totalCapacity = function (resinVolume, hardness) {
let exchange = 50;
return (resinVolume * exchange) / hardness;
};
let softener = totalCapacity(50, 200);
console.log(softener + ' m3');
This is an immediately invoked function:
(const totalCapacity = function (resinVolume, hardness) {
let exchange = 50;
return (resinVolume * exchange) / hardness;
};
let softener = totalCapacity(50, 200);
console.log(softener + ' m3');)();
<script language = "JavaScript">
function multiply() {
with(document.multiplication) {
result.value=x.value * y.value;
}
}
</script>
<form name="multiplication">
<input type="text" name="x" size="5">
<input type="text" name="y" size="5">
<input type="text" name="result" size="5"><br>
<input type="button" value="Multiply" onClick="multiply()">
You can get some idea from the above example.