/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] Dynamic css

hi All,
I am desperately seeking help regards my following problem 😮
In my website i want to give user a choice of background color selection. So lets say if he selects blue, the bgcolor becomes blue. I have used css div for page layout. Now I thought of creating different css and dynamically loading on the choice of user. But i am unable to do that. Can someone suggest how to solve this problem.

Thanks in advance

to post a comment
CSS

6 Comments(s)

Copy linkTweet thisAlerts:
@dumb_progSep 11.2008 — hi All,

I am desperately seeking help regards my following problem :eek:

In my website i want to give user a choice of background color selection. So lets say if he selects blue, the bgcolor becomes blue. I have used css div for page layout. Now I thought of creating different css and dynamically loading on the choice of user. But i am unable to do that. Can someone suggest how to solve this problem.

Thanks in advance[/QUOTE]


I would suggest you to use some kind of javascript or onclick event.

onclick="this.classname=' '" ( this will allows you to change your bgcolor based on your classname in your css)
Copy linkTweet thisAlerts:
@menewbeeauthorSep 15.2008 — I tried calling javascript function.

<script language="JavaScript">

function startup(cssName) {

var headID = document.getElementsByTagName("head")[0];

var cssNode = document.createElement('link');

cssNode.type = 'text/css';

cssNode.rel = 'stylesheet';

cssNode.href = cssName;

cssNode.media = 'screen';

headID.appendChild(cssNode);

}</script>

[B]and calling this function as follow[/B]

<body onload='startup("layoutBlue.css")'>

<div id = "header">

Lets try dynamic css<br>

<A HREF="javascript:startup("layoutRed.css");">Click here to change bgcolor.</A>

</div>

</body>

[B]It takes layoutBlue.css file onload event but doesn't work when i call it in <a> tag. Can plz someone tell me where am i going wrong



Thanks in advace[/B]
Copy linkTweet thisAlerts:
@menewbeeauthorSep 15.2008 — [B]I GOT THE ANSWER!

I was using wrong quotes.

It will be <A HREF='javascript: startup("layoutRed.css");'>Click here to change bgcolor.</A>[/B]
Copy linkTweet thisAlerts:
@magnum68Sep 17.2008 — hi all,

Who could make me the syntax global of the css ???
Copy linkTweet thisAlerts:
@LeeUSep 17.2008 — magnum68 : Don't hijack the thread. Open a new one for your questions.
×

Success!

Help @menewbee spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...