Search Results

Search found 1 results on 1 pages for 'user2371301'.

Page 1/1 | 1 

  • Set a specific stylesheet based on session variable in javascript

    - by user2371301
    I have an option for a user to select his/her own theme while logged into the system and this theme is set in a MYSQL Database and called each time the user logs in, this is called by: <?php $_SESSION['SESS_THEME_NAME']; ?> Now, I had this working in a PHP file but I need it to work in Javascript instead unfortunately. And I need some help. I looked at the code using the developers tools on Google Chrome and looks like the above code is not resolving within the javascript file. Which makes sense because you can't access session variables within a javascript file (as I found by searching Google.) The code is basically supposed to set the specific stylesheet based on the value extracted from the MYSQL database. So if the database says Default the script needs to tell the webpage to use the default.css file. And so on and so forth. My attempt at writing this is as follows: var themName="<?php $_SESSION['SESS_THEME_NAME']; ?>"; if (themeName == "Default") { document.write("<link re='stylesheet' type='text/css' href='css/mws-theme.css'>"); }; if (themeName == "Army") { document.write("<link rel='stylesheet' type='text/css' href='css/mws-theme-army.css'>"); }; if (themeName == "Rocky Mountains") { document.write("<link rel='stylesheet' type='text/css' href='css/mws-theme-rocky.css'>"); }; if (themeName == "Chinese Temple") { document.write("<link rel='stylesheet' type='text/css' href='css/mws-theme-chinese.css'>"); }; if (themeName == "Boutique") { document.write("<link rel='stylesheet' type='text/css' href='css/mws-theme-boutique.css'>"); }; if (themeName == "Toxic") { document.write("<link rel='stylesheet' type='text/css' href='css/mws-theme-toxic.css'>"); }; if (themeName == "Aquamarine") { document.write("<link rel='stylesheet' type='text/css' href='css/mws-theme-aquamarine.css'>"); }; Any help once so ever would be awesome and much much appreciated! I am reaching a deadline :/

    Read the article

1