Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

CSS Forum


You are currently viewing our CSS Forum as a guest. Please register to participate.
Login



Reply
Loading different CSS files based upon user selection?
Old 06-15-2010, 10:08 AM Loading different CSS files based upon user selection?
leebert45's Avatar
Novice Talker

Posts: 14
Name: Lee Wentzel
Location: Michigan, USA
Trades: 0
I am working on a person website, and want the person viewing to click on an image, which will then direct them to my main sight. Based upon which image they have chosen, I want the site to load a specific css file.

My initial image has a blue gem, yellow cheese, and green grass. Thus if they click the gem, then next page they go to would load the "blue.css" file. If they pick the cheese, it would load "yellow.css" and grass would load "green.css". I would probably have a default load if they bypass the welcome page.

My question is, am I going to need to do this with Javascript? Or can this be done just with xhtml or html? Thank you for your help with this matter.

Leebert45
leebert45 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 06-15-2010, 10:21 AM Re: Loading different CSS files based upon user selection?
Phunk Rabbit's Avatar
Ultra Talker

Posts: 255
Name: John Nerush
Location: Milton Keynes, UK
Trades: 0
PHP would be a good option.

You could put differnet GET requests on the links, for example:

HTML Code:
<a href="homepage.php?theme=blue">Blue Gem</a>
<a href="homepage.php?theme=yellow">Yellow Cheese</a>
<a href="homepage.php?theme=green">Green Grass</a>
<a href="homepage.php?theme=default">Skip</a>
Them on homepage.php you would get the theme from the url and load the stylesheet from there, for example:

PHP Code:
<?php
$stylesheet 
$_GET['theme'];

if(
$stylesheet !== 'blue' || $stylesheet !== 'yellow' || $stylesheet !== 'green' || $stylesheet !== 'default')
{
     
$stylesheet 'default';
}

$stylesheet '<link rel="stylesheet" type="text/css" href="/css/' $stylsheet '.css" />';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Welcome to your site</title>
<?php
echo $stylesheet;
?>
</head>
<body>
....... etc
__________________

Please login or register to view this content. Registration is FREE

Learn professional skills from professional people, from $6.50 a month.
Phunk Rabbit is offline
Reply With Quote
View Public Profile Visit Phunk Rabbit's homepage!
 
Old 06-15-2010, 02:31 PM Re: Loading different CSS files based upon user selection?
leebert45's Avatar
Novice Talker

Posts: 14
Name: Lee Wentzel
Location: Michigan, USA
Trades: 0
Thank you. Your sample is perfect... or rather would be perfect if my server I have my site on supported PHP. I know... what server doesn't support PHP now a days? Apparently mine. Thank you though.
leebert45 is offline
Reply With Quote
View Public Profile
 
Old 06-16-2010, 04:31 AM Re: Loading different CSS files based upon user selection?
Phunk Rabbit's Avatar
Ultra Talker

Posts: 255
Name: John Nerush
Location: Milton Keynes, UK
Trades: 0
You could replicate this in JS, I just dont know it well enough to comfortably type up an example for you, however there is a JS framework around that replicates many PHP functions, php.js or somthing.

Hope you find your solution.
__________________

Please login or register to view this content. Registration is FREE

Learn professional skills from professional people, from $6.50 a month.
Phunk Rabbit is offline
Reply With Quote
View Public Profile Visit Phunk Rabbit's homepage!
 
Reply     « Reply to Loading different CSS files based upon user selection?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 1.38488 seconds with 12 queries