PHP Classes

File: assets/switch-templates/select.php

Recommend this page to a friend!
  Classes of mohammad anzawi   PHP Multilingual Support Library   assets/switch-templates/select.php   Download  
File: assets/switch-templates/select.php
Role: Example script
Content type: text/plain
Description: Example script
Class: PHP Multilingual Support Library
Translate texts for Web sites from JSON or DB
Author: By
Last change:
Date: 3 years ago
Size: 702 bytes
 

Contents

Class file image Download
<select id='<?=$id?>' class='logaty-switcher'>
    <?php foreach ($this->app->enabled() as $lang) : ?>
<option <?=($lang == logaty()->current() ? 'selected ': '')?>class='logaty-switcher__option' value='<?= $this->app->link('', $lang) ?>'>
            <?= $this->app->nameN($lang); ?>
</option>
    <?php endforeach; ?>
</select>
<script>
    window['select_element_' + '<?=$id?>'] = document.getElementById('<?=$id?>');

    window['select_element_' + '<?=$id?>'].onchange = function () {
        let elem = (typeof this.selectedIndex === undefined ? window.event.srcElement : this);
        window.location.href = elem.value || elem.options[elem.selectedIndex].value;
    }
</script>