Jump to content

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>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.