V
V
viktorulyushev2016-11-09 16:27:41
JavaScript
viktorulyushev, 2016-11-09 16:27:41

Bitrix. How to update the price when choosing a size?

The product has a certain number of sizes, a price is attached to each size.
c5012b08b1e24e7d981c659409c1fd9b.PNG
I need to make sure that when choosing a size, the price changes depending on what price is set for this size. I was able to display the sizes, but how to update the price 348e517c66f9448cab519b4dc825bf1d.PNG
? :

<select  class="input-select" >
      <?foreach($arResult['SIZES'] as $id => $size):?>
        <option  value="<?=$id?>"><?=$size?></option>
      <?endforeach;?>
      </select>

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Severus256, 2016-11-09
@severus256

hang an on-change event on your select. Next, I change the value of the element with the price to the desired one, depending on the selected size

S
Sergey, 2016-11-09
@gangstarcj

Convert to trade offers. That will be more correct

V
viktorulyushev, 2016-11-09
@viktorulyushev

<select onchange="showPrice(this);"  class="input-select" >
    <?foreach($arResult['SIZES'] as $id => $size):?>
        <option  value="<?=$id?>" data-price><?=$size?></option>
    <?endforeach;?>
</select>

function showPrice(e) {
            $('.total_cost').html(e.options[e.selectedIndex].getAttribute('data-price'));
        }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question