Thursday, February 27, 2014

Make currency values into wordings using simple php

<?php
function no_to_words($no)
{  
 $words = array('0'=> '' ,'1'=> 'one' ,'2'=> 'two' ,'3' => 'three','4' => 'four','5' => 'five','6' => 'six','7' => 'seven','8' => 'eight','9' => 'nine','10' => 'ten','11' => 'eleven','12' => 'twelve','13' => 'thirteen','14' => 'fouteen','15' => 'fifteen','16' => 'sixteen','17' => 'seventeen','18' => 'eighteen','19' => 'nineteen','20' => 'twenty','30' => 'thirty','40' => 'fourty','50' => 'fifty','60' => 'sixty','70' => 'seventy','80' => 'eighty','90' => 'ninty','100' => 'hundred &','1000' => 'thousand','100000' => 'lakh','10000000' => 'crore');
    if($no == 0)
        return ' ';
    else {
$novalue='';
$highno=$no;
$remainno=0;
$value=100;
$value1=1000;      
            while($no>=100)    {
                if(($value <= $no) &&($no  < $value1))    {
                $novalue=$words["$value"];
                $highno = (int)($no/$value);
                $remainno = $no % $value;
                break;
                }
               $value= $value1;
                $value1 = $value * 100;
            }      
          if(array_key_exists("$highno",$words))
              return $words["$highno"]." ".$novalue." ".no_to_words($remainno);
          else {
             $unit=$highno%10;
             $ten =(int)($highno/10)*10;          
             return $words["$ten"]." ".$words["$unit"]." ".$novalue." ".no_to_words($remainno);
           }
    }
}
$a="$45,256.50";
$badsymbols=array("$",",");//remove bad symbols
$b=str_replace($badsymbols,"",$a);//remove commas in numbers
 $sample=ceil($b);
 echo no_to_words($sample);

?>

Wednesday, February 26, 2014

type to copy text from one to another textbox using simple javascript


html:-
<input type="text" id="simple" name="ship_quantity"  onkeyup="copy_data(this)" />
<input type="text" name="ship_quantity" id="ship_quantity" />

javascript

function copy_data(val){
     var a = document.getElementById("simple").value;

     document.getElementById("ship_quantity").value=a;
    }

Saturday, February 22, 2014

horizantal menu slide up and down using jquery

<script type="text/javascript">
$(document).ready(function(){

    $(".box-category").children("ul").hide(); //hides the lists when documents loads


    $(".box-category").hover(
        function(){//onmouseover
            $(this).children("ul").slideDown();
        },
        function(){//onmouseout
            $(this).children("ul").slideUp();
    });
});
</script>

note:-

class name=>  $(".box-category");
id=> $("#box-category");