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> 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? 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... 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? 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 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. Link to comment https://forums.phpfreaks.com/topic/198791-if-class/#findComment-1043352 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.