Page 1 of 1

Javascript/CSS/PHP all rolled into one...

Posted: Fri Dec 03, 2004 2:33 pm
by Todd_Z
I have a style chooser on my site which is a php session variable, what this then does is it will import whichever style the user wants. The thing is that when I do this, i want to somehow declare javascript variables in those css files... is there any way to do this? if not... can it easily and effeciently be done in another fashion? Thanks in advance...

Posted: Sat Dec 04, 2004 12:45 am
by rehfeld
you cant really use js in a css file, but its easy to make a dynamically generated js file:

Code: Select all

<?php

if ($stylesheet == 'foobarbaz') {
    $jsvar = 'bar';
}

if ($jsvar == 'foo') {
    echo 'var jsvar = "foo"';
} else {
    echo 'var jsvar = "bar";
}

?>
yes it is possible to get values from the stylesheet using js, but its not trivial imo


i think "easily and efficiently" could only be answered depending upon the context and extent of your desired use.

Posted: Sat Dec 04, 2004 3:05 pm
by Todd_Z
Is there a way to make javascript variables from php?

Posted: Sat Dec 04, 2004 5:39 pm
by Weirdan
Todd_Z wrote:Is there a way to make javascript variables from php?
Search these forums. We discussed it sooooo many times...