A
A
Andrey Smirnov2016-02-02 21:06:34
PHP
Andrey Smirnov, 2016-02-02 21:06:34

How to insert a modal window from Javascript into this piece of Smarty code?

Hello everyone, please help, I broke my head. There is a module on the site, written in the Smarty templating language. Here is the code:

{* DEFAULT FORM LAYOUT / pure CSS *}
{literal}
<script type="text/javascript">
function fbht(htid)
  {
    var fbhtc=document.getElementById(htid);
    if (fbhtc)
      {
      if (fbhtc.style.display == 'none')
        {
        fbhtc.style.display = 'inline';
        }
      else
        {
        fbhtc.style.display = 'none';
        }
      }
}
</script>
{/literal}
{$fb_form_header}
{if $fb_form_done == 1}
  {* This first section is for displaying submission errors *}
  {if isset($fb_submission_error) && $fb_submission_error}
    
  {/if}
{else}
  {* this section is for displaying the form *}
  {* we start with validation errors *}


  {* and now the form itself *}
  {$fb_form_start}
  <div>{$fb_hidden}</div>
  <div{if $css_class != ''} class="{$css_class}"{/if}>
  {if $total_pages gt 1}<span>{$title_page_x_of_y}</span>{/if}
  {foreach from=$fields item=entry}
    {if $entry->display == 1}
      {strip}
      {if $entry->needs_div == 1}
        <div
        {if $entry->required == 1 || $entry->css_class != '' || $entry->valid == 0} class="
          {if $entry->required == 1}required{/if}
          {if $entry->css_class != ''} {$entry->css_class}{/if}
          {if $entry->valid == 0} fb_invalid{/if}
          "
        {/if}
        >
      {/if}
      {if $entry->hide_name == 0}
        <label{if $entry->multiple_parts != 1} for="{$entry->input_id}"{/if}>{$entry->name}
        {if $entry->required_symbol != ''}
          {$entry->required_symbol}
        {/if}
        </label>
      {/if}
      {if $entry->multiple_parts == 1}
        {section name=numloop loop=$entry->input}
          {if $entry->label_parts == 1}
            <div>{$entry->input[numloop]->input}&nbsp;{$entry->input[numloop]->name}</div>
          {else}
            {$entry->input[numloop]->input}
          {/if}
          {if isset($entry->input[numloop]->op) && $entry->input[numloop]->op}{$entry->input[numloop]->op}{/if}
        {/section}
      {else}
        {if $entry->smarty_eval == '1'}{eval var=$entry->input}{else}{$entry->input}{/if}
      {/if}
      {if $entry->helptext != ''}&nbsp;<a href="javascript:fbht('{$entry->field_helptext_id}')"><img src="modules/FormBuilder/images/info-small.gif" alt="Help" /></a>
          <span id="{$entry->field_helptext_id}" style="display:none" class="fbr_helptext">{$entry->helptext}</span>{/if}
    
      {if $entry->needs_div == 1}
      {$submit} </div>
      {/if}
      {if $entry->valid == 0}<div style="text-align: center; color: rgb(199, 73, 73); margin-top: 10px; position: absolute; width: 355px; padding: 10px 15px 10px 15px; background: #F7F7F7; webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box;"><span style="width: 0; height: 0; border-left: 10px solid transparent; border-right: 10px solid transparent; border-bottom: 13px solid #F7F7F7; border-top: 0;position:absolute;top:-9px;left:50px"></span>{$entry->error}</div>{/if}
      {/strip}
    {/if}
  {/foreach}

  {if $has_captcha == 1}
    <div class="captcha">{$graphic_captcha}{$title_captcha}<br />{$input_captcha}</div>
  {/if}

  </div>
  {$fb_form_end}
{/if}
{$fb_form_footer}

In this code, this is what is done - a form is created with a button Call me back, by clicking on which the phone number that was entered is sent to the mail and that's it. That is, we receive a letter with a phone number to call back.
Question: since now it’s just a button press, that is, I pressed it and everything was updated and that’s it., then there was a need for a modal window (yes, at least in a simple alert, God. The essence of which is: you clicked on the button and a window with the text is displayed You will be called back in within 10 minutes. This raises the question - how can I insert javascript into this code? In smart, I'm not boom-boom at all, Javascript and PHP are more or less. So explain and I'll understand. I really hope for your help.
PS The question also arose because I saw in the code {submit } line, but since there is no explicit setting of the button - this is what led me to a dead end.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey, 2016-02-02
@VladimirAndreev

{$submit} - Displays the $submit variable set by the php code that causes this template to render.
if there is a button - it may have an id, to the edge - wrap it with {$submit} and hang the handler on something like this selector: #formSubmitContainer>input[type="submit"]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question