Hi there,
I’m opening this thread after a long time. We had an intense discussion over other intricacies.
For now, it seems that I am stuck at achieving something which was working fine before.
The pricetag –
This one should also update when the checkboxes ticked.
But that is not happening. All the script is dependent on the classes. So the HTML under discussion – if we put the class totalprice
Then the HTML starts to get updated → <h2 class="price license_price themecolor">€59</h2>
If we change to →
<h2 class="totalprice themecolor">€59</h2>
But then button’s add to Cart Button on the selection of checkboxes or drop-down fails to get updated.
My issue is: Previously everything was working fine:
Both add to cart button and the HTML above were updating simultaneously. what mistake or accidental change I have done because of which I am seeing a failure of anticipated results.
function getPriceEl(form) {
return form.querySelector(".license_price");
}
function getCheckboxPrice(checkbox) {
return checkbox.parentNode.querySelector(".license_price").innerHTML;
}
Both of these functions return a single result.
function updatePrice(select, prices) {
var price = getPriceEl(select.form);
price.innerHTML = "€" + prices[select.selectedIndex];
}
So this function updates a single element’s value.
You’ve put multiple instances of a total value into the page, but only told your function to update one of them. So that’s what it does.