Number in k, m, B
by Prabakaran[ Edit ] 2012-08-30 17:40:33
<script type='text/javascript' src='hioxframework/public/js/jquery.js'></script>
<script type='text/javascript'>
$(document).ready(function() {
$("#no").focus();
});
function s(){
window.location.href='test.php';
}
function d(){
var t=$("#no").val();
if(t){
window.location.href='?val='+t;
}else{
$("#info").html("Enter Proper Value........!");
}
}
function c(){
var t=$("#no").val();
t=t.replace(/[A-Za-z \@\!\#\$\%\^\&\*\(\)\~\`/\[\]\|\\\?\>\,\:\;\<\-]+/,"");
$("#no").val(t);
}
function typetest(e){
var keyvalue = (window.event) ? event.keyCode : e.keyCode;
if(keyvalue==13){
d();
}
}
</script>
<center>
<span id='info' height='30px;'></span><br>
<input type='text' value='' id='no' onkeyup='c()' onkeydown="typetest(event);"><input type='button' value='Enter' onclick='d()' >
<input type='button' value='Reload' onclick='s()'>
<br>
<?php
$b="<br>";
$val=$_GET['val'];
echo numConversion($val)."$b";
function numConversion($val){
if($val>1000 && $val<999999){
$val=round($val/1000);
return $val."K";
}else if($val>1000000 && $val<999999999){
$val=round($val/1000000);
return $val."M";
}else if($val>1000000000){
$val=round($val/1000000000);
return $val."B";
}else{
return $val;
}
}
?>
</center>