SitePoint Sponsor |
|
User Tag List
Results 1 to 2 of 2
-
Apr 18, 2007, 22:08 #1
- Join Date
- Sep 2006
- Posts
- 398
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
adding and removing code (to switch styles)
i know there are other ways to do this, but i specificaly need to do it this way. its actually a lot simpler i would think, i just cant figure out how to do this
all i want to do have the all the css in my code so that it would look like this
<style type="text/css">
#style 1 {
}
#style 2 {
}
</style>
<style type="text/css">
#style 1 {
}
#style 2 {
}
</ style >
so supposably if the divs have the same ids, the one in the bottom will be used to style the page so what i want to do is wrap the second set of style as comments, so that they will be ignored
<style type="text/css">
#style 1 {
}
#style 2 {
}
</style>
<! --
<style type="text/css">
#style 1 {
}
#style 2 {
}
</ style >
-->
now the first ones will be used.
SO finally what i want to do, is have some sort of javascript that will insert and remove the tags that make them comments. Dont need cookies or anything just reall simple. once again i know that this can be done other ways but for my current situation i need it to be like this
is there any way to do this?
thanks
-
Apr 18, 2007, 23:34 #2
- Join Date
- Sep 2006
- Posts
- 398
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
nevermind i figured it out with php. heres the code incase anyone is interested
<?php
$thestyle = $_GET['set'];
if ($thestyle == "style1")
{
$thestyle = "<! --";
}
else
{
$thestyle = " ";
}
$thestyle2 = $_GET['set'];
if ($thestyle == "style1")
{
$thestyle2 = "-->";
}
else
{
$thestyle2 = " ";
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<style type="text/css">
<!--
#test {
background-color: #999900;
}
-->
</style>
<?php echo($thestyle);?>
<style type="text/css">
<!--
#test {
background-color: #ffff00;
}
-->
</style>
<?php echo($thestyle2);?>
</head>
<body>
<a href="styleswitcher.php?set=style1">Style Sheet One</a>
<a href="styleswitcher.php?set=style2">Style Sheet Two</a>
<div id="test">Content for id "test" Goes Here</div>
</body>
</html>
Bookmarks