Monday, January 16, 2017

Convert Numbers To Words With JavaScript

Convert Numbers To Words With JavaScript
    <script>
    var s_num = ["Zero","One","Two","Three","Four","Five","Six","Seven","Eight","Nine","Ten","Eleven","Twelve","Thirteen","Fourteen","Fifteen","Sixteen","Seventeen","Eighteen","Nineteen","Twenty","Thirty","Fourty","Fifty","Sixty","Seventy","Eighty","Ninety",""];

    function NumericToChar(str)
    {
       
        number = str;
        i_part = parseInt(number);
        f_part = str.slice(-2);

        var s_text = "Rupees ";

        if(i_part >= 0 && i_part <= 20)
        {
            s_text += s_num[i_part];
        }
        if(i_part >= 21 && i_part <= 99)
        {
            i_str_part = i_part.toFixed();
            ch = i_str_part.slice(0, 1);
            if(ch != "0") s_text += s_num[parseInt(ch)+18]+" ";
            ch = i_str_part.slice(1, 2);
            if(ch != "0") s_text += s_num[parseInt(ch)];
        }
        if(i_part >= 100 && i_part <= 999)
        {
            i_str_part = i_part.toFixed();
            ch = i_str_part.slice(0, 1);
            if(ch != "0") s_text += s_num[parseInt(ch)]+" Hundred ";
            ch = i_str_part.slice(1, 2);
            if(ch != "0") s_text += s_num[parseInt(ch)+18]+" ";
            ch = i_str_part.slice(2, 3);
            if(ch != "0") s_text += s_num[parseInt(ch)];
        }
        if(i_part >= 1000 && i_part <= 9999)
        {
            i_str_part = i_part.toFixed();
            ch = i_str_part.slice(0, 1);
            if(ch != "0") s_text += s_num[parseInt(ch)]+" Thousand ";
            ch = i_str_part.slice(1, 2);
            if(ch != "0") s_text += s_num[parseInt(ch)]+" Hundred ";
            ch = i_str_part.slice(2, 3);
            if(ch != "0") s_text += s_num[parseInt(ch)+18]+" ";
            ch = i_str_part.slice(3, 4);
            if(ch != "0") s_text += s_num[parseInt(ch)];
        }
        if(i_part >= 10000 && i_part <= 99999)
        {
            i_str_part = i_part.toFixed();
            s_text = GetText(i_str_part.slice(0, 2))+" Thousand ";
            ch = i_str_part.slice(2, 3);
            if(ch != "0") s_text += s_num[parseInt(ch)]+" Hundred ";
            ch = i_str_part.slice(3, 4);
            if(ch != "0") s_text += s_num[parseInt(ch)+18]+" ";
            ch = i_str_part.slice(4, 5);
            if(ch != "0") s_text += s_num[parseInt(ch)];
        }
        if(i_part >= 100000 && i_part <= 999999)
        {
            i_str_part = i_part.toFixed();
            ch = i_str_part.slice(0, 1);
            if(ch != "0") s_text += s_num[parseInt(ch)]+" Lac ";
            s_text += GetText(i_str_part.slice(1, 3))+" Thousand ";
            ch = i_str_part.slice(3, 4);
            if(ch != "0") s_text += s_num[parseInt(ch)]+" Hundred ";
            else s_text += s_num[parseInt(ch)+28]+" ";
            s_text += GetText(i_str_part.slice(4, 6));
        }
        if(i_part >= 1000000 && i_part <= 9999999)
        {
            i_str_part = i_part.toFixed();

            s_text += GetText(i_str_part.slice(0, 2))+" Lac ";
            s_text += GetText(i_str_part.slice(2, 4))+" Thousand ";
            ch = i_str_part.slice(4, 5);
            if(ch != "0") s_text += s_num[parseInt(ch)]+" Hundred ";
            ch = i_str_part.slice(5, 6);
            if(ch != "0") s_text += s_num[parseInt(ch)+18]+" ";
            ch = i_str_part.slice(6, 7);
            if(ch != "0") s_text += s_num[parseInt(ch)];
        }
        if(i_part >= 10000000 && i_part <= 99999999)
        {
            i_str_part = i_part.toFixed();
            ch = i_str_part.slice(0, 1);
            if(ch != "0") s_text += s_num[parseInt(ch)]+" Crore ";
            s_text += GetText(i_str_part.slice(1, 3))+" Lac ";
            s_text += GetText(i_str_part.slice(3, 5))+" Thousand ";
            ch = i_str_part.slice(5, 6);
            if(ch != "0") s_text += s_num[parseInt(ch)]+" Hundred ";
            else s_text += s_num[parseInt(ch)+28]+" ";
            s_text += GetText(i_str_part.slice(6, 8));
        }

        s_text += " and ";

        ch = f_part.slice(0, 1);
        if(ch == "0")
        {
            ch = f_part.slice(1, 2);
            if(ch != "0") s_text += s_num[parseInt(ch)]+" ";
            else s_text += "Zero";
        }
        else
        {
            s_text += GetText(f_part.slice(0, 2));
        }

        s_text += " Paise Only";
        return s_text;
    }

    function GetText(ch)
    {
            str = ch;
            i_part = parseInt(str);

            if(i_part >= 0 && i_part <=20)
                s_text = s_num[i_part];

            if(i_part >= 21 && i_part <= 99)
            {
                ch = str.slice(0, 1);
                if(ch != "0") s_text = s_num[parseInt(ch)+18];
                ch = str.slice(1, 2);
                if(ch != "0") s_text += " "+s_num[parseInt(ch)];
            }

        return s_text;
    }

    document.write(NumericToChar('99999999.99'));
    </script>

Tuesday, January 10, 2017

How to Create Awesome Profile Web Page Using HTML, CSS and Javascript


<html>
<head>
<style>
.divstyle {position:absolute; left:0%; top:0%; width:99%; height:99%; text-align:center; }
.divbutton { position:absolute; left:1%; width:97%; height:10%; background:#3399ff; border-radius:4px; cursor:crosshair;}
</style>
<body style="background:#0080ff;">
<div class="divstyle">
<div class="divstyle" style="width:20%; border:1px solid blue; background:#8000ff;">
<div class="divbutton" onclick="About();" style="top:1%; opacity:0.5;"><a style="font-size:32px;">About Me</a></div>
<div class="divbutton" onclick="Quali();" style="top:12%; opacity:0.6;"><a style="font-size:32px;">My Qualification</a></div>
<div class="divbutton" onclick="Profile();" style="top:23%; opacity:0.7;"><a style="font-size:32px;">My Profile</a></div>
<div class="divbutton" onclick="Hobbies();" style="top:34%; opacity:0.8;"><a style="font-size:32px;">My Hobbies</a></div>
<div class="divbutton" onclick="Contact();" style="top:45%; opacity:0.9;"><a style="font-size:32px;">Contact Info</a></div>
</div>
<div class="divstyle" style="left:20%; width:80%;">
<img src="stones.jpg" style="width:100%; height:100%;">
<div class="divstyle" style="left:5%; top:5%; width:55%; height:10%; background:blue; opacity:0.5; font-size:40px; color: red">Vijay Kumar Singh</div>
<div class="divstyle" style="left:5%; top:20%; width:55%; height:70%; background:blue; opacity:0.5; border-radius:8px; text-align:left">
<a id="text" style="color:white; font-size:32px;"></a>
</div>
<div class="divstyle" style="left:70%; top:20%; width:25%; height:50%; border:1px solid blue;">
<img src="aris.jpg" style="width:100%; height:100%;"></div>
<div class="divstyle" style="left:65%; top:15%; width:35%; height:10%; background:blue; opacity:0.3;"></div>
<div class="divstyle" style="left:92%; top:18%; width:8%; height:60%; background:blue; opacity:0.3;"></div>
<div class="divstyle" style="left:62%; top:65%; width:35%; height:10%; background:blue; opacity:0.3;"></div>
<div class="divstyle" style="left:65%; top:12%; width:8%; height:60%; background:blue; opacity:0.3;"></div>
</div>
</div>
<script>
document.oncontextmenu = function() { return false; }
obj = document.getElementById("text");
function About()
{ obj.innerHTML = "Hi, my name is Vijay.<br>On internet I am vijayevol.<br>I am a Software Enginner."; }
function Quali()
{obj.innerHTML = "I have completed my MCA in 2004 followed by graduation with PCM."; }
function Profile()
{ obj.innerHTML = "Name: Vijay Kumar Singh<br>Gender: Male<br>Nationality: Indian<br>Birthday: 15th November<br>Languages: Hindi, English"; }
function Hobbies()
{ obj.innerHTML = "My hobbies are:<br><br>Playing & Watching Cricket<br>Cooking<br>Playing PC Games<br>Making Friends"; }
function Contact()
{ obj.innerHTML = "Contact Number: 9810043147<br>Email: vijayevol@yahoo.co.in<br>Facebook, Twitter, Google+ and Whatsapp"; }
</script>
</body>
</html>