How to set current page active when menu in php file

Active menu item is simple when we go with HTML but when we develop website through PHP, its little bit difficult. As in HTML we can simply call active class for each menu label, here we need to write some dynamic CSS, here our hope/clue is URL . Based on URL we can do some magic. Lets assume we have class called "current" and we want this class active based on page we areee...


Code is simple look how i convert,




<ul id="menu" >

          <li class="activemenu"><a title="Home" href="index.php">Home</a></li>

          <li class="activemenu"><a title="About us" href="about-us.php">About us</a></li>

          <li class="activemenu"><a title="services" href="services.php">Services</a></li>

          <li class="activemenu"><a title="Security Doors" href="security-doors.php">Security Doors</a></li>

         

          <li class="activemenu"><a title="Gallery" href="gallery.php">Gallery</a></li>

          <li class="activemenu"><a title="Contact Us" href="contact.php">Contact Us</a></li>

        </ul>


Dynamic CSS Menu reading page URL


<ul id="menu" >

          <li class="<?php if(basename($_SERVER['SCRIPT_NAME']) == 'index.php'){echo 'activemenu'; }else { echo ''; } ?>"><a title="Home" href="index.php">Home</a></li>

          <li class="<?php if(basename($_SERVER['SCRIPT_NAME']) == 'about-us.php'){echo 'activemenu'; }else { echo ''; } ?>"><a title="About us" href="about-us.php">About us</a></li>

          <li class="<?php if(basename($_SERVER['SCRIPT_NAME']) == 'services.php'){echo 'activemenu'; }else { echo ''; } ?> activemenu"><a title="services" href="services.php">Services</a></li>

          <li class="<?php if(basename($_SERVER['SCRIPT_NAME']) == 'security-doors.php'){echo 'activemenu'; }else { echo ''; } ?>"><a title="Security Doors" href="security-doors.php">Security Doors</a></li>

         

          <li class="<?php if(basename($_SERVER['SCRIPT_NAME']) == 'gallery.php'){echo 'activemenu'; }else { echo ''; } ?>"><a title="Gallery" href="gallery.php">Gallery</a></li>

          <li class="<?php if(basename($_SERVER['SCRIPT_NAME']) == 'contact.php'){echo 'activemenu'; }else { echo ''; } ?>"><a title="Contact Us" href="contact.php">Contact Us</a></li>

        </ul>


Now you can call your menu <?php include 'menufilename.php';?> on any php page.

How to fix W3C CSS3 validation errors for box-shadow?

Now a days so many people wants their website HTML and CSS bugs/error  free ,. So they test website by submitting  to major W3C validation website for finding  the errors, Anyway here i am explaining how to get rid of  from the issue.. box- shadow errors. Well we have other W3C errors too, but i will explain in my next post.

Just like others i also develop websites in better manner with latest web techniques like CSS3 and HTML 5 but when i test my website i always face more errors with CSS compared to HTML and the one of my most disturbing error is with box-shadow because i love developing websites with shadow effects rather than using Photoshop techniques ,as i always want my developed website load quickly. So whenever  we  need use box shadow effect its better to use like below,

box-shadow:0px  5px 5px  #eee;

in place of,
-moz-box-shadow: 0px  5px 5px  #eee;
-webkit-box-shadow: 0px  5px 5px  #eee;



Comments are welcome for this posts and also if you have any doubts, thanks for reading my post.
 

Onclick hide for single or multiple div, table,tr,.. Tags with the same function name Using Javascript

Onclick hide for single or multiple div, table,tr,.. Tags with the same function name can be done using IDs. Mostly these types of code are used for dynamic contents which are generated from Mysql and so on. Any way the code is as follows: <html>
<head>
<script>
function hide(str)
{
var elem = document.getElementById(str);
elem.style.display = 'none';
}

</script>
</head>
<body>

<h2 align="center">Using the display property of CSS</h2>

<a href="#" onclick="hide(this.id);" id="1">Here is some text which I want to hide</a>
<a href="#" onclick="hide(this.id);" id="2">Here is some text which I want to hide</a>
<a href="#" onclick="hide(this.id);" id="3">Here is some text which I want to hide</a>

</body>
</html> Note: This code also be used by putting ID s for div, table, tr and so on.. In the same time you are also able to call onclick function by setting them in a button. As you know in above I put id and I also called function in same anchor tag, if you observe. I hope this code is very useful for you. Happy coding

Code for moving particular area of the page

Code for moving particular area of the page is mainly useful when the web pages are lengthy and also for easily moving to top of the page from bottom of the same page. It's simple one line code with anchor tag and id.

Meanwhile, if you want to navigate to particular area of the same page than the anchor tag will be,<a href="#cf" >  and,
if you want to navigate to particular area of some other page than the anchor tag will be, <a href="onlinewebprt.html#cf" > , but condition is that particular are should be kept in id tag which is mentioned in the anchor tag. As here i mentioned id as cf so particular content will be in


<div id="cf">
 <p>----------------------</p> </div>


Displaying current date in textbox at page on load

Displaying current date in textbox at page on load is very with a single function, I checked this function by putting the script in between head tags but i didn't work, Then again i put in the body section then it working perfectly.
This function reads current system time of our PC. But i am not fully satisfy with this code i want to be with global internet date. Mean while the code is as follows , hope it will helpful you guys.