I am using this code to switch language in my website. Everything works fine but when I change language always first item is selected. I want to keep selected which language is website language. Here is my code.
<td width="85%" align=right class=top_section>
<form method='POST'>
<select name="switchlanguage" onchange="this.form.submit()">
<option value="en" <?php if($_POST['switchlanguage'] == 'en') echo 'selected';?>English</option>
<option value="ru" <?php if($_POST['switchlanguage'] == 'ru') echo 'selected';?>Русский</option>
<option value="tj" <?php if($_POST['switchlanguage'] == 'tj') echo 'selected';?>Точики</option>
</select>
</form>
</td>
How to make it work properly? If russian language is selected it should stay in russian. But it always goes to English.
And using this code to change website language
if(!isset($_POST['switchlanguage']))
{
include_once($DOCUMENT_LANG.'en.lng.php');
}
else
{
include_once($DOCUMENT_LANG.$_POST['switchlanguage'].'.lng.php');
}
Even when I use tab to enter dropdownbox and using down key, it is automatically goes to first item.