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

It doesn't matter if you do all the error checking in the world, or if you have the most beautiful graphics, if your site or application design isn't usable, it's not going to do well. Get input and advice on usability and user interface issues here.

Moderator: General Moderators

Post Reply
User avatar
Todd_Z
Forum Regular
Posts: 708
Joined: Thu Nov 25, 2004 9:53 pm
Location: U Michigan

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

Post 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...
rehfeld
Forum Regular
Posts: 741
Joined: Mon Oct 18, 2004 8:14 pm

Post 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.
User avatar
Todd_Z
Forum Regular
Posts: 708
Joined: Thu Nov 25, 2004 9:53 pm
Location: U Michigan

Post by Todd_Z »

Is there a way to make javascript variables from php?
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

Todd_Z wrote:Is there a way to make javascript variables from php?
Search these forums. We discussed it sooooo many times...
Post Reply