TimberVis Flexiboard: Visualization and Exploration Flexiboard for Timber Buildings IoT data sensors. The pulse of the wood Monitoring of Wooden houses: Time series of sensors data measuring humidity, temperatures, vibrations and weather conditions. https://lnu.se/forskning/forskningsprojekt/projekt-flexiboard-for-visualisering-och-utforskning-av-trabyggnader/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

80 lines
2.5 KiB

<!DOCTYPE html>
<html>
<head>
<title>Calculator</title>
</head>
<body>
<h1>'m form.html : Simple Calculator</h1>
<form id="calculatorForm">
<label for="num1">Number 1:</label>
<input type="number" id="num1" name="num1" required><br>
<label for="num2">Number 2:</label>
<input type="number" id="num2" name="num2" required><br>
<button type="submit">Calculate</button>
</form>
<h1>Form 2: Another Form</h1>
<form id="anotherForm">
<!-- Include fields for Form 2 here -->
<button type="submit">Submit</button>
</form>
<h1>Form 3: Third Form</h1>
<form id="thirdForm">
<!-- Include fields for Form 3 here -->
<button type="submit">Submit</button>
</form>
<h1>Form 4: Fourth Form</h1>
<form id="fourthForm">
<!-- Include fields for Form 4 here -->
<button type="submit">Submit</button>
</form>
<h2>Result:</h2>
<div id="result"></div>
<script>
function handleSubmit(formId, fieldIds) {
const form = document.getElementById(formId);
form.addEventListener("submit", function (e) {
e.preventDefault();
const data = {
form_name: formId, // Add a form identifier
};
fieldIds.forEach(fieldId => {
data[fieldId] = parseFloat(form.querySelector(`#${fieldId}`).value);
});
calculate(formId, data);
});
}
function calculate(formId, data) {
fetch("/calculate", {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify(data)
})
.then(response => response.json())
.then(data => {
document.getElementById("result").textContent = `Result for form ${formId}: ${data.result}`;
})
.catch(error => {
console.error("Error:", error);
});
}
// Call handleSubmit for each form when the DOM is fully loaded
document.addEventListener("DOMContentLoaded", function () {
handleSubmit("calculatorForm", ["num1", "num2"]);
handleSubmit("anotherForm", ["field1", "field2"]);
handleSubmit("thirdForm", ["field3", "field4"]);
handleSubmit("fourthForm", ["field5", "field6"]);
});
</script>
</body>
</html>