Friday, April 5, 2013

How to raplace one page to another address ?

 By using the following Javascript we can redirect from current page to another address.
<script>
window.onbeforeunload = function () {
   location.replace('http://www.google.com');
   return "This session is expired and the history altered.";
}
</script>
Note: Placed in header is preferable one. 

Tuesday, April 2, 2013

In PHP, how to search a value existed or not in array?

By using in_array function we can knows the element existed or not in that array.

Syntax:

         in_array('search_array_value',$search_array);

Example:

$fruits=array('Apple','Bananna','grapes','Mango');  

In the above array fruits we want to know the array having 'Bananna' value or not!

 if (in_array('Bananna',$fruits))
        {
                   echo 'Fruits having Bananna';
        }
        else
        {
                  echo 'Fruits doesn't having Bananna';
        }

Monday, April 1, 2013

How to add confirmation box to forms using Javascript?

No need to worry, it's a simple task. By adding "onclick" function to submit buttons.
syntax:  
onclick="return confirm('Do you like to proceed?');"
Example: 
<input type="submit" name="submit" value="Submit" onclick="return confirm('Do you like to proceed?');">