A
A
Andrey Glukhovskoy2021-12-01 03:04:55
WordPress
Andrey Glukhovskoy, 2021-12-01 03:04:55

Advanced custom fields - how to change content on button click?

There are three colors to choose from (implemented by buttons), grey, pink and white (each button has a value with a color name). How can I change the content of the block using Advanced custom fields if gray color is selected? But when clicking on white, the content changed to a different value?

Example

<p>Выберите цвет:</p>
<?php
  // переменные
  $colors = get_field('cveta');
  // проверка и вывод кнопок с цветами
  if( $colors ): ?>
  <div class="choice-color">
    <?php foreach( $colors as $color ): ?>
    <button class="<?php echo $color; ?>" value="<?php echo $color; ?>"></button>
    <?php endforeach; ?>
  </div>
<?php endif; ?>
<div class="output">
//Если нажимаем на серую кнопку
//Показать блок 1
//Если нажимаем на серебрянную кнопку
//Показать блок 2, скрыв остальные блоки
</div>


Thank you in advance.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question