IPB

Welcome Guest ( Log In | Register )

 

Outline · [ Standard ] · Linear+

 Now You See It, Now You Don't, In need of an if/then

InfiniteWarrior
post Oct 2 2005, 02:58 PM
Post #1


Emperor


Group: Members
Posts: 724
Joined: 21-June 03
Member No.: 20



For the option to turn styles off and on, I'm using this little snippet:

CODE
<?php
if( $_GET['css'] != 'false' )
{
?>
 <link rel="stylesheet" href="style.css" type="text/css" />
<?php
}
?>


... and the links:

CODE
<a href="?css=false">Styles Off</a> | <a href="?css=true">Styles On</a>


... meaning both links are visible at all times. What I'd like to do is make one or the other disappear depending on which has been selected: "Styles Off" becomes "Styles On" and vice versa.

Any of you youngsters wanna help out an old lady?
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
Kyzene
post Oct 2 2005, 06:51 PM
Post #2


Master


Group: -=RJ=-Clan
Posts: 497
Joined: 18-June 03
Member No.: 13



Reading all that crazyness made my brain hurt. C++ is so much more...normal rolleyes.gif


--------------------
There is no such thing as luck, only mistakes and the people that take advantage of them.

Play Wild Jedi CTF in JA.
Visit Chop Shop for crazy CTF action.
Become a Pastafarian.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
Ruggiero
post Oct 2 2005, 06:56 PM
Post #3


Lord


Group: Admin
Posts: 1,171
Joined: 13-June 03
Member No.: 2



I KNOW Liz has seen this thread.... I just don't know if he knows the answer. wink.gif

Rugg


--------------------
Oobawanga wata chopay polah.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
TheLizardKing
post Oct 2 2005, 07:05 PM
Post #4


Secretive Rodian Lover Hater


Group: Admin
Posts: 93
Joined: 13-June 03
From: Orlando, Florida, United States of America
Member No.: 1



well what you could do is decide what you would like to have set by default. If you want css on by default you should then just simply write some code that says something like.

<?php

if (isset($_GET['css'])) {
$headercss = "<link rel="stylesheet" href="style.css" type="text/css" />"

$linktext = "<a href=blah.php?css=false">Styles Off</a>"
} else {
$linktext = "<a href=blah.php">Styles On</a>"
}

?>

And place the appropriate $variables where ye need them to be.


--------------------
AS;LDJFA;LSKFADS
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
InfiniteWarrior
post Oct 2 2005, 10:03 PM
Post #5


Emperor


Group: Members
Posts: 724
Joined: 21-June 03
Member No.: 20



Thanks for the edification, Msr. Lizard. 'Twould be on by default. I'll try it.

Please forgive my PHP illiteracy, but how might one write those appropriate variables when placing them? Also, I'd like "off" to refresh any page the user happens to be on and have it stay that way until the "on" link was clicked again (from anywhere), but I'm thinking a cookie would be necessary to carry the preference. Will this code avoid that?
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
TheLizardKing
post Oct 3 2005, 09:53 PM
Post #6


Secretive Rodian Lover Hater


Group: Admin
Posts: 93
Joined: 13-June 03
From: Orlando, Florida, United States of America
Member No.: 1



For the variables, all you have to do is place that bit of code (its not 100% syntax correct) near the top and place the header variable in the header and the link variable where the link is

html <?php echo $linktext; ?> morehtml

and for the persistant memory, you are gonna want to look into sessions. Unfortunately I am not the master of sessions so I can't help much there sad.gif


--------------------
AS;LDJFA;LSKFADS
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
InfiniteWarrior
post Oct 4 2005, 06:08 PM
Post #7


Emperor


Group: Members
Posts: 724
Joined: 21-June 03
Member No.: 20



Ah, dat's ok. Should have seen the sessions coming, but I have a lifeline for those. Thank you ever so much!

~ Infi
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

Topic Options
2 User(s) are reading this topic (2 Guests and 0 Anonymous Users)
0 Members:
 

Lo-Fi Version Time is now: 26th July 2017 - 11:37 AM