<td colspan="2" align="center">
    <h2>{$params_tpl['title']}{$params_tpl['help']}</h2>
    <div style="display: flex; flex-direction: column;">{$tpl_types['url']}</div>
    <div style="display: flex; flex-direction: column;">{$tpl_types['field']}</div>
</td>
<script>
    (function() {
        var url = $('textarea[name="calc_params[{$tpl_num}][url]"]');
        var flexField = $('select[name="calc_params[{$tpl_num}][field]"]');

        $(flexField).prepend('<option value="" selected></option>');

        $(flexField).change(function() {
            if ($(this).val() == "") {
                return;
            }

            var text = url.val();
            var option = $('option[value="' + $(this).val() +'"]');
            {literal}
            var optinForInsert = '{' + option.html() + '}';
            var position = $(url).prop('selectionStart');
            text = text.substr(0, position) + optinForInsert + text.substr(position);
            {/literal}

            url.val(text);
            var index = this.selectedIndex;
            var indextext = this.selectedIndex.innerHTML;
            var indexVal = flexField[0][index].getAttribute('value');

            $(url).change()
            this.selectedIndex = 0;
        });
    })();
</script>
