Results 1 to 3 of 3

Thread: Help! Select drop down to change colour scheme

Hybrid View

  1. #1
    Join Date
    Mar 2013

    Question Help! Select drop down to change colour scheme

    HELP! I will try to make this as short and painless as possible. I have a select drop down menu that allows a user to change the colour scheme of my webpage ultimately by using .setAttribute and changing the "href" attribute to locate a different style sheet. Here is my problem, when I click a link to go to another page within my site it reverts back to the original colour scheme, I am not sure how exactly I would get my script to remember what the selectedIndex is on the previous loaded page. Here is my javascript:

    "var styleSheet=document.getElementById("stylez");
    var checker;

    function changeColour() {
    styleSheet.setAttribute("href", "styles/styles.css");
    styleSheet.setAttribute("href", "styles/styles02.css");

    if(checker==1) {
    styleSheet.setAttribute("href", "styles/styles.css");
    if(checker==2) {
    styleSheet.setAttribute("href", "styles/styles02.css");

    The if statements at the end there are my attempt to get it to load the correct colour scheme, but what I am thinking is that the variable checker is equal to null because it is redeclared when the script is loaded on a new HTML page.

    How can I fix this?

    All comments are welcome, and thank you for any advice you may give

  2. #2
    Join Date
    Mar 2013
    http://www.andrew-horn.com/ <---This is the site in reference to.

  3. #3
    Join Date
    Dec 2005
    I believe if you load (or re-load) a different page (href=...), the browser will automatically initialize to the original settings.

    You might possibly call the page with the latest color choices using a query string as part of the link structure.
    See about using a 'querystring' in your script to read the passed parameters. Missing parameters could default to the original colors.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center

Recent Articles