A
A
Alexander Gorkin2018-08-05 18:19:11
JavaScript
Alexander Gorkin, 2018-08-05 18:19:11

How to update a div element on button click?

How to update a div element without reloading the page. When you click the add button. I know that this is implemented using Ajax, but I can’t figure out how exactly.
5b67156030f5d486780613.png

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Дмитрий Ким, 2018-08-06
@kimono

Можно использовать такую структуру:

Pjax::begin()
Form [data-pjax='']
Итого: Yii::$app->cart->getTotalSum();
Pjax::end()

Максим Тимофеев, 2018-08-06
@webinar Куратор тега Yii

Я знаю что это реализуется с помощью Ajax

No, this is implemented using js (jquery), ajax is also possible, but not required. As I understand it, you have all the data, there is a price, there is a quantity, why ajax? After all, you just need to multiply two numbers.
$('.someButton').on('click',function(){
   var price = $('.someInputeSelector').val();
   var count = $('.someInpute2Selector').val();
   var summ = price * count;
   $('.someSelector').text('Итого:' + summ + 'рублей');
});

Why ajax?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question