Goal: When onChange script loads new URL, selected value has to change too for displaying new selected value.
Problem: Selected value does not update after onChange action but will do so after refresh. It will set the cookie "lng" to correct value as it should.
When user selects new language I set it to user cookie file under "lng". With PHP I get the value but it does not update the selected value.
Here is my code:
<select onChange="if (this.value) window.location.href=this.value" class="form-control">
<option <?php if($_COOKIE['lng'] === "EN") { echo "selected='seleceted'"; } ?> value="/">English</a></option>
<option <?php if($_COOKIE['lng'] === "FI") { echo "selected='seleceted'"; } ?> value="/fi/">Suomi</option>
<option <?php if($_COOKIE['lng'] === "ET") { echo "selected='seleceted'"; } ?> value="/et/">Eesti</option>
<option <?php if($_COOKIE['lng'] === "SV") { echo "selected='seleceted'"; } ?> value="/sv/">Svenska</option>
<option <?php if($_COOKIE['lng'] === "FR") { echo "selected='seleceted'"; } ?> value="/fr/">Français</option>
<option <?php if($_COOKIE['lng'] === "IT") { echo "selected='seleceted'"; } ?> value="/it/">Italiano</option>
</select>
selected="selected"doesn't work on Firefox.