V
V
Vladimir2017-01-29 00:23:41
PHP
Vladimir, 2017-01-29 00:23:41

How to implement a phone number change when choosing a city on Bitrix?

Hello!
I'm trying to implement a change of context on the choice of the city on Bitrix.
Without connecting to any geo-base, because the number of cities is known.
Moscow and Peter.
When you enter the site, a window pops up, there is a RADIO BUTTON And the Select button Choose
Peter at the bottom of the page, the phone number changes.
I created an infoblock with the name of the city and the PHONE property
. I use bitrix.news.list
Here is my code without popup.

<div class="news-list">
<?foreach($arResult["ITEMS"] as $arItem):?>
    <?if($arParams["DISPLAY_NAME"]!="N" && $arItem["NAME"]):?>
      <?if(!$arParams["HIDE_LINK_WHEN_NO_DETAIL"] || ($arItem["DETAIL_TEXT"] && $arResult["USER_HAVE_ACCESS"])):?>
<form name ="" method ="post">
<input type="radio" name="r"><b><?echo $arItem["NAME"]?></b><br />
      <?endif;?>
    <?endif;?>
<?endforeach;?>
<input type = "submit" value = "Выбрать">
  </form>
</div>
</div>
            <?if (isset($_POST['r'])):?>
        <?foreach($arItem["DISPLAY_PROPERTIES"] as $pid=>$arProperty):?>
               <div id="telephone"> <?=$arProperty["DISPLAY_VALUE"];?></div><br />
        <?endforeach;?>
<?endif?>
</div>
</div>

Accordingly, the substitution of the number does not work (
9cdd7c6ae5124ed2a7ca87f1f2453746.png
I don’t even know what to do. It’s very necessary that it works automatically if cities are suddenly added or phones change.
Help, please.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey, 2017-01-29
@gangstarcj

Write the currently selected city ID to the cookie. Yes, and the phone can also be entered there and then removed from the cookies. If there are no cookies, then display the phone by default

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question