Answer the question
In order to leave comments, you need to log in
How to rebuild this code for OpenCart3?
Good day, I want to redo the code, I have a code that changes the HTML values, and I need it to change the VALUE in the input, now I will send the standard OpenCart3 code and mine)
There is nothing like that just to adjust
<input type="text" name="quantity[{{ product.cart_id }}]" value="{{ product.quantity }}" size="1" class="form-control" />
<div class="row counter">
<input type="button" class="remove-counter" id="buttonCountMinus" value="-">
<div id="buttonCountNumber">1</div>
<input type="button" class="add-counter" id="buttonCountPlus" value="+">
</div>
<div id="price" style="opacity: 0;">350</div>
<div id="calculation" class="price-cart cart-counter">350</div>
<div class="row price-count" style="color: #d70506;">
<div class="price-counter">350 x </div>
<input type="text" style="width: 20%; border: none; background: none; position: relative; left: 3px; color: #d70506;" value="1" id="num" class="cart-counter" name="num" readonly>
</div>
<div class="col-10 full-price-row" style="margin-top: 5%;">
<div class="row row-price">
<p class="start-price-text" style="font-weight: 400;">Итого:</p>
<div style="margin-right: 3%;" id="calculation-2" class="full-price">350 грн</div>
</div>
</div>
<div class="col-10 full-price-row">
<div class="row row-price" style="color: #d70506;">
<p class="full-price-text" style="font-weight: 400;">Сумма к оплате:</p>
<div style="margin-right: 3%; margin-top: 1%;" id="calculation-3" class="full-price">350 грн</div>
</div>
</div>
let calculate = document.getElementById("calculation");
let count = document.getElementById("buttonCountNumber");
let count2 = document.getElementById("num");
let number = 1;
calculation = document.getElementById("calculation").innerHTML;
let calculate2 = document.getElementById("calculation-2");
calculation2 = document.getElementById("calculation-2").innerHTML;
let calculate3 = document.getElementById("calculation-3");
calculation3 = document.getElementById("calculation-3").innerHTML;
document.getElementById("buttonCountPlus").onclick = function() {
let countPlus = count.innerHTML;
if(+countPlus <= 3){
number++;
count.innerHTML++;
count2.value = number;
let countPlus = count.innerHTML;
calculate.innerHTML = calculations(countPlus) ;
calculate2.innerHTML = calculations2(countPlus) ;
calculate3.innerHTML = calculations3(countPlus) ;
}
}
document.getElementById("buttonCountMinus").onclick = function() {
let countMinus = count.innerHTML;
if(+countMinus >= 2){
number--;
count.innerHTML--;
count2.value = number;
let countMinus = count.innerHTML;
calculate.innerHTML = calculations(countMinus) ;
calculate2.innerHTML = calculations2(countMinus) ;
calculate3.innerHTML = calculations3(countMinus) ;
}
}
calculations = (count) => {
return (+count)*(+calculation);
}
calculations2 = (count) => {
return (+count)*(+calculation) + ` ` + `грн`;
}
calculations3 = (count) => {
return (+count)*(+calculation) + ` ` + `грн`;
}
Answer the question
In order to leave comments, you need to log in
If something your code does not work, there are errors, but this is the lyrics.
<input type="number" id="calculation" value="350" />
//Читаем value у элемента выше
let calculation = document.getElementById("calculation").value;
console.log(calculation);
//меняем value вместо тех мест где .innerHTML
let calculation1 = document.getElementById("calculation").value = "234";
console.log(calculation1);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question