Advertisement
Guest User

Untitled

a guest
Sep 11th, 2015
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.77 KB | None | 0 0
  1. #form.result.new/template.php
  2. <?
  3. if(!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true)die();
  4. ?>
  5.  
  6. <span id="getcard" class="white-popup mfp-hide">
  7.         <div id="msg">
  8.             <?if ($arResult["isFormErrors"] == "Y"):?>
  9.                 <div id="fail"><?=$arResult["FORM_ERRORS_TEXT"];?></div>
  10.             <?endif;?>
  11.             <?if($arResult["FORM_NOTE"]):?>
  12.                 <div id="success"><?=$arResult["FORM_NOTE"];?></div>
  13.             <?endif;?>
  14.         </div>
  15.  
  16.  
  17.     <?if ($arResult["isFormNote"] != "Y" || $arResult["isFormNote"] != "N")
  18.     {
  19.         ?>
  20.         <? if ($_REQUEST['AJAX_REQUEST'] !== 'Y') {?>
  21.         <form id="card-form" class="card-form" method="POST" action="<?=POST_FORM_ACTION_URI?>" enctype="multipart/form-data" name="<?=$arResult["WEB_FORM_NAME"]?>">
  22.             <? } ?>
  23.             <input type="hidden" name="WEB_FORM_ID" value="<?= $arParams["WEB_FORM_ID"] ?>">
  24.             <?= bitrix_sessid_post() ?>
  25.             <? foreach ($arResult["QUESTIONS"] as $FIELD_SID => $arQuestion) {?>
  26.                 <div>
  27.                     <? if (is_array($arResult["FORM_ERRORS"]) && array_key_exists($FIELD_SID, $arResult['FORM_ERRORS'])):?>
  28.                         <span class="error-fld" title="<?= $arResult["FORM_ERRORS"][$FIELD_SID] ?>"></span>
  29.                     <? endif; ?>
  30.                     <div id="form-fio">
  31.                         <? if ($arQuestion["CAPTION"] == "Имя"):?>
  32.                             <!--<label><?/*= $arQuestion["CAPTION"] */?>: <?/* if ($arQuestion["REQUIRED"] == "Y"):*/?><span style="color: red;">*</span><?/* endif; */?></label>-->
  33.                             <input type="<?= $arQuestion["STRUCTURE"]["0"]["FIELD_TYPE"] ?>" name="form_text_<?= $arQuestion["STRUCTURE"]["0"]["ID"] ?>" id="name"  placeholder="Ваше имя*"/>
  34.                         <? endif ?>
  35.                     </div>
  36.                     <div id="form-contact">
  37.                         <? if ($arQuestion["CAPTION"] == "E-mail"):?>
  38.                             <!--<label><?/*= $arQuestion["CAPTION"] */?>: <?/* if ($arQuestion["REQUIRED"] == "Y"):*/?><span style="color: red;">*</span><?/* endif; */?></label>-->
  39.                             <input type="<?= $arQuestion["STRUCTURE"]["0"]["FIELD_TYPE"] ?>" name="form_email_<?= $arQuestion["STRUCTURE"]["0"]["ID"] ?>" id="email" placeholder="Ваш E-mail*"/>
  40.                         <? endif ?>
  41.                         <? if ($arQuestion["CAPTION"] == "Номер телефона"):?>
  42.                             <!--<label><?/*= $arQuestion["CAPTION"] */?>: <?/* if ($arQuestion["REQUIRED"] == "Y"):*/?><span style="color: red;">*</span><?/* endif; */?></label>-->
  43.                             <input type="<?= $arQuestion["STRUCTURE"]["0"]["FIELD_TYPE"] ?>" name="form_text_<?= $arQuestion["STRUCTURE"]["0"]["ID"] ?>" id="form-tel" placeholder="+7 (999) 999-99-99*"/>
  44.                         <? endif ?>
  45.                     </div>
  46.                 </div>
  47.                 <?
  48.             } //endwhile
  49.             ?>
  50.             <? if ($arResult["isUseCaptcha"] == "Y") {?>
  51.                 <tr>
  52.                     <th colspan="2"><b><?= GetMessage("FORM_CAPTCHA_TABLE_TITLE") ?></b></th>
  53.                 </tr>
  54.                 <tr>
  55.                     <td>&nbsp;</td>
  56.                     <td><input type="hidden" name="captcha_sid"
  57.                                value="<?= htmlspecialcharsbx($arResult["CAPTCHACode"]); ?>"/><img
  58.                             src="/bitrix/tools/captcha.php?captcha_sid=<?= htmlspecialcharsbx($arResult["CAPTCHACode"]); ?>"
  59.                             width="180" height="40"/></td>
  60.                 </tr>
  61.                 <tr>
  62.                     <td><?= GetMessage("FORM_CAPTCHA_FIELD_TITLE") ?><span style="color: red;">*</span></td>
  63.                     <td><input type="text" name="captcha_word" size="30" maxlength="50" value="" class="inputtext"/>
  64.                     </td>
  65.                 </tr>
  66.                 <?
  67.             } // isUseCaptcha
  68.             ?>
  69.  
  70.             <input <?= (intval($arResult["F_RIGHT"]) < 10 ? "disabled=\"disabled\"" : ""); ?> type="submit" class="submit" id="submit" name="web_form_submit" value="<?= htmlspecialcharsbx(strlen(trim($arResult["arForm"]["BUTTON"])) <= 0 ? GetMessage("FORM_ADD") : $arResult["arForm"]["BUTTON"]); ?>"/>
  71.             <div style="display: inline-block; margin-left: 15px;">
  72.                 <p style="margin-top: 10px;">
  73.                     <span style="color: red;">*</span> - <?= GetMessage("FORM_REQUIRED_FIELDS") ?>
  74.                 </p>
  75.             </div>
  76.             <div class="clearfix"></div>
  77.             <? if ($_REQUEST['AJAX_REQUEST'] !== 'Y') {?>
  78.         </form>
  79.             <? } ?>
  80.             <script>
  81.         $(document).ready(function () {
  82.             // Отправка AJAX запроса
  83.             $('body').on('submit', '#card-form', function(e) {      // Обработка отправки данных формыc
  84.                 e.preventDefault();                  // Сброс стандартного обработчика формы
  85.                 formData = $(this).serialize() + "&web_form_submit=Заказать карту";
  86. // Сохраняем массив введенных данных включая значение кнопки "Отправить", без этого компонент Битрикса не примет данные
  87.                 $.ajax({
  88.                     method: "POST",
  89.                     url: $(this).attr('action') + '?AJAX_REQUEST=Y',
  90.                     data: {formData},
  91.                     dataType: "html",
  92.                     success: function( data ) {
  93.                         //var $data = $.parseHTML(data);
  94.                         $("#card-form").html(data);
  95.                     }
  96.                 });
  97.                 e.preventDefault();
  98.                 return false;
  99.             });
  100.         });
  101.     </script>
  102.     <? } //endif (isFormNote)?>
  103.  
  104.     </span>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement