note4

Saturday, October 6, 2018

2:36 PM



code here

code........


 <style type="text/css">
 
  </style>
  <!-- TODO: Missing CoffeeScript 2 -->

  <script type="text/javascript">


    window.onload=function(){
   
var NUMBER2TEXT = {
    ones: ['', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen'],
    tens: ['', '', 'twenty', 'thirty', 'fourty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety'],
    sep: ['', ' thousand ', ' million ', ' billion ', ' trillion ', ' quadrillion ', ' quintillion ', ' sextillion ']
};

(function( ones, tens, sep ) {

    var input = document.getElementById( 'input' ),
        output = document.getElementById( 'output' );
 
    input.onkeyup = function() {
        var val = this.value,
            arr = [],
            str = '',
            i = 0;
     
        if ( val.length === 0 ) {
            output.textContent = 'Please type a number into the text-box.';
            return;
        }
     
        val = parseInt( val, 10 );
        if ( isNaN( val ) ) {
            output.textContent = 'Invalid input.';
            return; 
        }
     
        while ( val ) {
            arr.push( val % 1000 );
            val = parseInt( val / 1000, 10 ); 
        }
     
        while ( arr.length ) {
            str = (function( a ) {
                var x = Math.floor( a / 100 ),
                    y = Math.floor( a / 10 ) % 10,
                    z = a % 10;
             
                return ( x > 0 ? ones[x] + ' hundred ' : '' ) +               
                       ( y >= 2 ? tens[y] + ' ' + ones[z] : ones[10*y + z] );
            })( arr.shift() ) + sep[i++] + str;                   
        }
     
        output.textContent = str;     
    };
 
})( NUMBER2TEXT.ones, NUMBER2TEXT.tens, NUMBER2TEXT.sep );

    }

</script>


<style>
div.a {
    text-transform: uppercase;
}

div.b {
    text-transform: lowercase;
}

div.c {
    text-transform: capitalize;
}
</style>

<style>
input[type=text] {
    width: 100%;
    padding: 12px 20px;
    margin: 8px 0;
    box-sizing: border-box;
    border: 2px solid red;
    border-radius: 4px;
}
</style>

</head>
<body>

<input name="text" type="text" id="input">

<div class="a"><p id="output"> </p>
</div>

0 comments: