drayarms Posted December 24, 2012 Share Posted December 24, 2012 I'm building a site with both jQuery mobile and native HTML5. I send a PHP cookie named "language" from the site to the browser to and assign it a value of either "english" or "spanish" depending on user input. Then I use the function below to output all content on the site in the language chosen <?php function translate ($english_txt,$spanish_txt){ switch ($_COOKIE['language']){ case "english": echo $english_txt; break; case "spanish": echo $spanish_txt; break; default: echo $english_txt; }//End of switch }//End of translate function ?> Here is example of a paragraph printed on the website using this fucntion <p> <?php translate("Happy New Year","Feliz Navidad"); ?> </p> Everything works just fine on the HTML site. With the jQM site however, only the default case is echoed. But I do know for a fact that the cookie exists (I used the isset funtion to verify that) and I also know for a fact that the value of the cookie is either "spanish" or "english" depending on the user input. Yet I'm puzzled as to why the conditional doesn't work in jQM. Keep in mind that it works in HTML. I also tried using the if conditional thus: <?php if($_COOKIE['language']=="english"){echo "Happy New Year";} if($_COOKIE['language']=="spanish"){echo "Feliz Navidad";} ?> to no avail. Anyone can tell me what I'm not doing right? Quote Link to comment https://forums.phpfreaks.com/topic/272343-php-conditionals-not-working-as-expected-in-jquery-mobile/ Share on other sites More sharing options...
PFMaBiSmAd Posted December 24, 2012 Share Posted December 24, 2012 What does var_dump($_COOKIE['language']); show? Quote Link to comment https://forums.phpfreaks.com/topic/272343-php-conditionals-not-working-as-expected-in-jquery-mobile/#findComment-1401190 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.