Bitrix.How to update price when choosing size?

The product has a number of sizes,each size is tied to the price
c5012b08b1e24e7d981c659409c1fd9b.PNG
I need to make when choosing size,price changed depending on what the price is set to this size.Able to put the size,but the price to upgrade?Populated with only 1 value348e517c66f9448cab519b4dc825bf1d.PNG
Sizes derived this way:
<select class="input-select">
 <?foreach($arResult['SIZES'] as $id =--> $size):?>
 <option value="<?=$id?>"><?=$size?></option>
<?endforeach;?>
 </select>
July 2nd 19 at 18:13
3 answers
July 2nd 19 at 18:15
to hang on event-change to your select statement. Then I the value of an element with price on needed, depending on size
example
stackoverflow.com/questions/5024056/how-to-pass-pa... - arturo.Wilkinson commented on July 2nd 19 at 18:18
could you see the code below?why is not working? - kristian.Schul commented on July 2nd 19 at 18:21
: what exactly is not working? Need more info :) - arturo.Wilkinson commented on July 2nd 19 at 18:24
: well, it is in data-price enters a new price,just nothing displays - kristian.Schul commented on July 2nd 19 at 18:27
July 2nd 19 at 18:17
To alter trade offers. It would be more correct
it is possible more in detail? - arturo.Wilkinson commented on July 2nd 19 at 18:20
: https://dev.1c-bitrix.ru/learning/course/?COURSE_I... - kristian.Schul commented on July 2nd 19 at 18:23
: I have already used trade relations - arturo.Wilkinson commented on July 2nd 19 at 18:26
And in the code it seems that you are simply a property. If you do have the SKU in some cases for 15 minutes to do everything. Js to write the handler as said above - kristian.Schul commented on July 2nd 19 at 18:29
only the sizes specified in the item and not trade offers - kristian.Schul commented on July 2nd 19 at 18:32
: Well, it's not a trade offer then. Just property - Mabel commented on July 2nd 19 at 18:35
: I have a lot of goods,and that now each will have a new property to add?+ I did not,and I'm not sure that this can be changed,I think a better handler,but how do I get then the size of the properties to change when prices change? - kristian.Schul commented on July 2nd 19 at 18:38
: Add the attribute data-price tag option which contains the size. When you switch to take the data from the attribute data and change text in div (span) in which is stored the price.
Well, to add to write a custom add to cart where you will pass your price - Mabel commented on July 2nd 19 at 18:41
below code resulted,so chtoli? - kristian.Schul commented on July 2nd 19 at 18:44
is it for some reason,it resets the price if you switch - Mabel commented on July 2nd 19 at 18:47
July 2nd 19 at 18:19
<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'));
 }

Find more questions by tags 1C-BitrixJavaScript