Wednesday 26 December 2012

Show/hide div on click event


Step-1 :

Use below javascript code with you div ID. like "myDivBox".


<script language="javascript" type="text/javascript">
       function toggleDiv() 
       { 
         if (document.getElementById("myDivBox").style.display == "block") 
         { 
           document.getElementById("myDivBox").style.display = "none"; 
         } 
         else 
         { 
           document.getElementById("myDivBox").style.display = "block"; 
         } 
       } 
</script>


Step-2 :

Add onclick() event on you button or whatever you use to show/hide div.
and make sure that..id of your div is same with javascript code use above.


<input type="button" id="button1" name="button1" OnClick="toggleDiv()"/>


    
    <div>
    
       <div id="myDivBox" style="display:none; width :300px">

              Content or your coding to hide in between this div.

       </div>

    </div>

Submit form on page load event


Step-1 :

Add below code into your <head> section. and change the form id as per your <form> tag.


<script type="text/javascript" language="javascript">

 function submitform(){

 document.getElementById('myForm').submit();

 }

</script>


Step-2 :


Add onload event in to body tag as per below.

<body onload="submitform()">

</body>

Friday 31 August 2012

convert min into hours using php


for converting the min into Hours you can use the following PHP function.

step for using PHP function :
1) call the function min2hours with parameter total min
2) and print the return value.


function min2hours($mins) { 

            if ($mins < 0) { 
                $min = Abs($mins); 
            } else { 
                $min = $mins; 
            } 

            $H = Floor($min / 60); 
            $M = ($min - ($H * 60)) / 100; 
            $hours = $H +  $M; 

            if ($mins < 0) { 
                $hours = $hours * (-1); 
            } 

            $expl = explode(".", $hours); 
            $H = $expl[0]; 

            if (empty($expl[1])) { 
                $expl[1] = 00; 
            } 

            $M = $expl[1]; 
            if (strlen($M) < 2) { 
                $M = $M . 0; 
            } 

            $hours = $H . ":" . $M; 
            return $hours; 
    } 

OUTPUT :

<?php echo min2hour(120); ?>

-- 2:00

Thursday 23 August 2012

Welcome to PHP-GHOST

Welcome to the PHP-GHOST...!!!!

In php ghost you can find the script and coding related to php.