kade119 Posted April 16, 2010 Share Posted April 16, 2010 What i'm trying to do but am a complete beginner.. is write a small php script that will make my menu item active based on the class and not the 'a' tag could someone help me? $class = ??? <div id="serviceBox"> <span class="jFlowControl"><a class="s-item1" <?php if ($class == 's-item1'){ ?>class="active"<?php } ?>></a></span> <span class="jFlowControl s-item2"><a></a></span> <span class="jFlowControl"><a class="s-item3"></a></span> <span class="jFlowControl"><a class="s-item4"></a></span> <span class="jFlowControl"><a class="s-item5"></a></span> </div> Quote Link to comment https://forums.phpfreaks.com/topic/198791-if-class/ Share on other sites More sharing options...
ignace Posted April 16, 2010 Share Posted April 16, 2010 First, it's: class="s-item1 active" and not class="s-item1" class="active" Second, what does $class contain? How does it get a value? AJAX? Quote Link to comment https://forums.phpfreaks.com/topic/198791-if-class/#findComment-1043338 Share on other sites More sharing options...
kade119 Posted April 16, 2010 Author Share Posted April 16, 2010 it currently contains nothing... i'm not sure where to begin.. i just know i need an "if else statement" that tells my "a" tag to use the active class if it's clicked... Quote Link to comment https://forums.phpfreaks.com/topic/198791-if-class/#findComment-1043344 Share on other sites More sharing options...
sspoke Posted April 16, 2010 Share Posted April 16, 2010 echo or print forgot them? Quote Link to comment https://forums.phpfreaks.com/topic/198791-if-class/#findComment-1043346 Share on other sites More sharing options...
Mchl Posted April 16, 2010 Share Posted April 16, 2010 That's job for JavaScript not PHP Quote Link to comment https://forums.phpfreaks.com/topic/198791-if-class/#findComment-1043350 Share on other sites More sharing options...
seventheyejosh Posted April 16, 2010 Share Posted April 16, 2010 +1 Javascript, Assuming this is based off of, say a click, and not off of the active url or anything. Quote Link to comment https://forums.phpfreaks.com/topic/198791-if-class/#findComment-1043352 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.