seventheyejosh Posted July 3, 2009 Share Posted July 3, 2009 Hey all. I was wondering if someone could give me a quick snippet that'll change every instance of one class to another onclick. So i can have an 'admin side of a forum without an actual one '. basically just a button -> <input type=button value="Enable Admin Mode" onclick="enable();"> and a little function that will change all of the classes. note: i know a bit of js, but obviosuly the following example would never ever work function enable(){ foreach element with class of 'adminhidden' update to class of 'admindisplayed' }//end function thanks Quote Link to comment Share on other sites More sharing options...
celsoendo Posted July 4, 2009 Share Posted July 4, 2009 Try to use Jquery or Protoype. Using one of them you can do this with 2 or 3 lines and keep it cross-browser. Quote Link to comment Share on other sites More sharing options...
haku Posted July 5, 2009 Share Posted July 5, 2009 Just to give you the heads up, this is horribly insecure. Anyone will be able to see the admin buttons in your source code, and can just change the css visibility themselves to get access to your admin panel. Quote Link to comment Share on other sites More sharing options...
seventheyejosh Posted July 5, 2009 Author Share Posted July 5, 2009 well im using (on this site) the smarty template engine, im not sure if you're familiar, but basically on the php side i'll do <? if (isset($is_admin)){ $smarty->assign('variable with admin divs',$variable); } ?> then the smarty will be $variable_with_admin_divs so basically, if the php perms dont match, not only will the 'button' never be created, but the divs it unlocks wont be either it wont even be in the source code. Quote Link to comment 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.