Чтобы решить проблему, в которой субтотальный не отображается правильно в резюме тележки внизу, мы должны убедиться, что JavaScript правильно обновляет значение для элемента .sub_total в резюме тележки, как и для таблицы. подтотальный. Не отображать подножку, как выполнить эту проблему, я - новый PHP Devloper < /p>
Cart Summary
.fixed-bottom-clr1 {
background-color: #f8f9fa;
}
.badgescntr {
position: absolute;
left: 33%;
}
.medium {
font-size: 1.2rem;
}
Price List
Product Name
Price
Quantity
Total
Product 1
50
50
Product 2
30
30
Subtotal:
80
2 items .
80.00
|
2
View Cart
// Function to update the total when quantity changes
document.querySelectorAll('.product-quantity').forEach(input => {
input.addEventListener('input', updateCart);
});
function updateCart() {
let totalItems = 0;
let subTotal = 0;
// Loop through all product rows and calculate the total and subtotal
document.querySelectorAll('.product-quantity').forEach(input => {
const quantity = parseInt(input.value) || 0;
const price = parseFloat(input.getAttribute('data-price')) || 0;
const productTotal = quantity * price;
// Update the individual product total
input.closest('tr').querySelector('.product-total').textContent = productTotal.toFixed(2);
// Update subtotal and total items
subTotal += productTotal;
totalItems += quantity;
});
// Update subtotal in both table and cart summary
document.querySelector('.sub_total').textContent = subTotal.toFixed(2);
document.querySelector('.total_products_count').textContent = totalItems;
}
// Initial call to update the cart
updateCart();
Подробнее здесь: https://stackoverflow.com/questions/793 ... t-not-show
Как подготовить общую сумму не показывать ⇐ Javascript
Форум по Javascript
1738119467
Anonymous
Чтобы решить проблему, в которой субтотальный не отображается правильно в резюме тележки внизу, мы должны убедиться, что JavaScript правильно обновляет значение для элемента .sub_total в резюме тележки, как и для таблицы. подтотальный. Не отображать подножку, как выполнить эту проблему, я - новый PHP Devloper < /p>
Cart Summary
.fixed-bottom-clr1 {
background-color: #f8f9fa;
}
.badgescntr {
position: absolute;
left: 33%;
}
.medium {
font-size: 1.2rem;
}
Price List
Product Name
Price
Quantity
Total
Product 1
50
[i]
50
Product 2
30
30
Subtotal:
80
2 items .
[/i] 80.00
|
2
[i][/i] View Cart
// Function to update the total when quantity changes
document.querySelectorAll('.product-quantity').forEach(input => {
input.addEventListener('input', updateCart);
});
function updateCart() {
let totalItems = 0;
let subTotal = 0;
// Loop through all product rows and calculate the total and subtotal
document.querySelectorAll('.product-quantity').forEach(input => {
const quantity = parseInt(input.value) || 0;
const price = parseFloat(input.getAttribute('data-price')) || 0;
const productTotal = quantity * price;
// Update the individual product total
input.closest('tr').querySelector('.product-total').textContent = productTotal.toFixed(2);
// Update subtotal and total items
subTotal += productTotal;
totalItems += quantity;
});
// Update subtotal in both table and cart summary
document.querySelector('.sub_total').textContent = subTotal.toFixed(2);
document.querySelector('.total_products_count').textContent = totalItems;
}
// Initial call to update the cart
updateCart();
Подробнее здесь: [url]https://stackoverflow.com/questions/79395638/how-to-sub-total-amount-not-show[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия