Results 1 to 4 of 4

Thread: Optional CSS templates on the same page

  1. #1

    Thread Starter
    Fanatic Member damasterjo's Avatar
    Join Date
    Nov 2005
    Location
    In front of my Comp DirectX7 EXpert
    Posts
    827

    Optional CSS templates on the same page

    How would I have a page that loads with one CSS document, then when they click a box somewhere, the CSS file will change and the site will look different. I want to have the user be able to dynamically change the appearance of the site to different files i create, so they can pick the one they like best
    Software languages known:
    Qbasic - TI-Basic - Liberty Basic - Visual Basic 6
    Software API's known:
    Directx 7 and 8
    Internet languages, in the process of learning:
    HTML - JAVASCRIPT - PHP - CSS - MYSQL - AJAX

  2. #2
    Hyperactive Member coothead's Avatar
    Join Date
    Oct 2007
    Location
    chertsey, a small town 25 miles south west of london, england.
    Posts
    285

    Re: Optional CSS templates on the same page

    Hi there damasterjo,

    have a look at this example, it may suit your requirements...
    Code:
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
       "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    
    <link id="styles" rel="stylesheet" type="text/css" href="style1.css">
    
    <script type="text/javascript">
    window.onload=function(){
    document.getElementById('choice').onchange=function() {
    document.getElementById('styles').href=this.value;
      }
     }
    </script>
    
    </head>
    <body>
    
    <div>
     <select id="choice">
      <option value="style1.css">style one</option>
      <option value="style2.css">style two</option>
      <option value="style3.css">style three</option>
      <option value="style4.css">style four</option>
     </select>
    </div>
    
    </body>
    </html>
    
    coothead

  3. #3

    Thread Starter
    Fanatic Member damasterjo's Avatar
    Join Date
    Nov 2005
    Location
    In front of my Comp DirectX7 EXpert
    Posts
    827

    Re: Optional CSS templates on the same page

    im sorry this dosent change the file when i choose an option, why not?
    Software languages known:
    Qbasic - TI-Basic - Liberty Basic - Visual Basic 6
    Software API's known:
    Directx 7 and 8
    Internet languages, in the process of learning:
    HTML - JAVASCRIPT - PHP - CSS - MYSQL - AJAX

  4. #4
    Hyperactive Member coothead's Avatar
    Join Date
    Oct 2007
    Location
    chertsey, a small town 25 miles south west of london, england.
    Posts
    285

    Re: Optional CSS templates on the same page

    Hi there damasterjo,
    I'm sorry this doesn't change the file when I choose an option, why not?
    Well, I can only assume that you are having problems with your coding.
    I have tested my code in IE6, IE7, Opera 9.27, Firefox 2 and Safari 3 with no problems.
    The attachment contains this test for you to try at your leisure.
    Attached Files Attached Files


    ~ the original bald headed old fart ~

Posting Permissions

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



Click Here to Expand Forum to Full Width