Hello everyone!

Such a problem when switching the language: only the last one in the list is switched, I can not understand what the problem is.

<form name="Lang_form" method="post" action="index.php"> <select onChange="lang_form()" name="new_language"> {section name=i loop=$lang_list} <option value="{$smarty.section.i.index}">{$lang_list[i]->description}</option> {/section} </select> </form> 
  • one
    And you can see the generated code and the function itself? By the way, try this: onСhange = "alert ('[' + this.value + ']')" - ling


1 answer 1

It would, of course, be nice to see the compiled template. Check option values ​​for values ​​— do they match what you expect? The option proposed by ling for this is suitable (alert). And, of course, the lang_form () function in the studio!

Respectfully,

  • here is the function {literal} <script type = "text / javascript" language = "JavaScript"> function lang_form () {document.Lang_form.submit (); } </ script> {/ literal} - Sergey Sergeev
  • and this is pxp code if (isset ($ _ POST ["new_language"])) {$ _SESSION ["current_language"] = $ _POST ["new_language"]; } if (! isset ($ _ SESSION ["current_language"]) || $ _SESSION ["current_language"] <0 || $ _SESSION ["current_language"]> count ($ lang_list)) $ _SESSION ["current_language"] = 0 ; if (isset ($ lang_list [$ _ SESSION ["current_language"]]) && file_exists ("./ languages ​​/".$ lang_list [$ _ SESSION [" current_language "] - -> filename)) include (" ./ languages ​​/ " . $ lang_list [$ _ SESSION ["current_language"]] -> filename); else {die ("<font color = red> <b> ERROR: Couldn't find language file! </ b> </ font>"); } - Sergey Sergeev
  • Can you see the html-code? - ling
  • What is the content of $ lang_list? And what exactly do you mean by saying that "only the last in the list is switched" - that only this language can be chosen? or is it the only one available? or that no others are included (although there is a list?). Are there any errors in the php error log? ... So far the situation is not entirely clear, there are no errors in your code (php) ... The only thing I can offer at the moment is to check the template initialization code ... you don't forget to execute $ smarty-> assign ('lang_list', $ lang_list); (or something like that, if you need it, of course) - gote
  • I mean that in the list 2 languages ​​Russian and English, Russian is the first second English. Choosing English in the list triggers English, choosing Russian, he does not even click i. Back to Russian does not switch. The html code is at the top, and the source code is <script type = "text / javascript" language = "JavaScript"> function lang_form () {document.Lang_form.submit (); } </ script> <form name = "Lang_form" method = "post" action = "index.php"> <select onChange = "lang_form ()" name = "new_language"> <option value = "0"> Russian < / option> <option value = "1"> English </ option> </ select> </ form> how to make the code visible - Sergey Sergeyev