This commit is contained in:
parent
eddd739c71
commit
888f8717b5
@ -111,34 +111,11 @@
|
|||||||
document.getElementById('submit-button').disabled = !(food && weight);
|
document.getElementById('submit-button').disabled = !(food && weight);
|
||||||
}
|
}
|
||||||
|
|
||||||
// function addProduct() {
|
|
||||||
// const foodInput = document.getElementById('my_combobox');
|
|
||||||
// const weightInput = document.getElementById('weight');
|
|
||||||
// const portionsInput = document.getElementById('portions');
|
|
||||||
// const food = foodInput.value;
|
|
||||||
// let weight = parseFloat(weightInput.value);
|
|
||||||
// const portions = Math.max(parseInt(portionsInput.value, 10), 1); // Stellt sicher, dass mindestens 1 Portion angegeben wird
|
|
||||||
|
|
||||||
// // Teilen des Gewichts durch die Anzahl der Portionen und Aufrunden
|
|
||||||
// weight = Math.ceil(weight / portions);
|
|
||||||
|
|
||||||
// fetch(`/add_lm?food=${encodeURIComponent(food)}&weight=${encodeURIComponent(weight)}`)
|
|
||||||
// .then(response => response.json())
|
|
||||||
// .then(data => {
|
|
||||||
// // Fügen Sie die verarbeitete Logik hier hinzu, wie zuvor
|
|
||||||
// })
|
|
||||||
// .catch(error => console.error('Fehler:', error));
|
|
||||||
// }
|
|
||||||
|
|
||||||
function addProduct() {
|
function addProduct() {
|
||||||
const foodInput = document.getElementById('my_combobox');
|
const foodInput = document.getElementById('my_combobox');
|
||||||
const weightInput = document.getElementById('weight');
|
const weightInput = document.getElementById('weight');
|
||||||
const food = foodInput.value;
|
const food = foodInput.value;
|
||||||
let weight = parseFloat(weightInput.value);
|
const weight = weightInput.value;
|
||||||
const portions = Math.max(parseInt(portionsInput.value, 10), 1); // Stellt sicher, dass mindestens 1 Portion angegeben wird
|
|
||||||
|
|
||||||
// Teilen des Gewichts durch die Anzahl der Portionen und Aufrunden
|
|
||||||
weight = Math.ceil(weight / portions);
|
|
||||||
|
|
||||||
|
|
||||||
fetch(`/add_lm?food=${encodeURIComponent(food)}&weight=${encodeURIComponent(weight)}`)
|
fetch(`/add_lm?food=${encodeURIComponent(food)}&weight=${encodeURIComponent(weight)}`)
|
||||||
@ -218,8 +195,7 @@ function updateTotalNutrition() {
|
|||||||
</datalist>
|
</datalist>
|
||||||
<input type="number" id="weight" name="weight" placeholder="Gramm" oninput="updateButtonState()">
|
<input type="number" id="weight" name="weight" placeholder="Gramm" oninput="updateButtonState()">
|
||||||
<button type="submit" id="submit-button" disabled>Hinzufügen</button>
|
<button type="submit" id="submit-button" disabled>Hinzufügen</button>
|
||||||
<input type="number" id="portions" name="portions" placeholder="Portionen" min="1" value="1">
|
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<table id="nutrition-table">
|
<table id="nutrition-table">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user