Jump to content

[SOLVED] drop-down box language change


mpempas

Recommended Posts

I need an expert help,

i have a drop-down select box and i would like to change language from here.

The code is working but the problem is:

1. When im changing language english is still the first in the drop-down box and i cant change back to english, so when change a language the defualt one would be the one im using.

2. If there is any way do not change website to ?locale=en/el just refresh and active this language.

 

Im using $_SESSION['langSYS']

  <form name='language_switcher' method='post'>
			<select name="language" id="language" onChange="location.href('?locale='+this.value)">
<option value="en">English</option>
<option value="el">Ελληνικά</option>
			</select></form>

 

thank you

Link to comment
https://forums.phpfreaks.com/topic/169266-solved-drop-down-box-language-change/
Share on other sites

The problem is, is that you are not using selected="selected"

 

<form name='language_switcher' method='post'>
     <select name="language" id="language" onChange="location.href('?locale='+this.value)">
          <option value="en"<?php echo ($_SESSION['langSYS'] == 'en')?' selected="selected"':'';?>>English</option>
          <option value="el"<?php echo ($_SESSION['langSYS'] == 'el')?' selected="selected"':'';?>>Ελληνικά</option>
     </select>
</form>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.