Thursday, 18 May 2017

Calculation of Each Row

<html>
   <head>
<script src="file:///E:/Scripts/jquery-1.7.1.min.js"></script>
<script>
$(document).ready(function()
 {
$('input[type=text][usedToSum="true"]').bind('blur',function(e)
{
  Data()
});
 });
 function Data()
  {
Basic=0,VAT=0,Sale=0,Excise=0,Quantity=0
$("table tr[det=product]").each(function()
 {
row_total = 0;
$("td:not(.Total) input",this).each(function()
     {
 if ($(this).parent().hasClass('Basic')) {
                   Basic = parseFloat($(this).val())
               }
 if ($(this).parent().hasClass('Quantity')) {
                   Quantity = parseFloat($(this).val())
               }
 if ($(this).parent().hasClass('Excise')) {
                   Excise = parseFloat($(this).val())
               }
 if ($(this).parent().hasClass('Sale')) {
                   Sale = parseFloat($(this).val())
               }
 if ($(this).parent().hasClass('VAT')) {
                   VAT = parseFloat($(this).val())
               }
});
row_total = parseFloat((Basic * Quantity) + ((Basic * Quantity)*(Excise + VAT + Sale)) / 100);
        $(".Total :input:text", this).val(row_total);
 });
  }
 function AddMore()
  {
 $("table tr:last").after('<tr det="product"><td class="Basic"><input type="text" id="Basic" usedToSum="true" onblur="Data()"></td><td class="Quantity"><input type="number" id="Quantity" min="1" max="100" onchange="Data()"></td><td class="Excise"><input type="text" usedToSum="true" onblur="Data()"></td><td class="Sale"><input type="text" id="Sale" onblur="Data()" usedToSum="true"></td>  <td class="VAT"><input type="text" id="VAT" onblur="Data()" usedToSum="true"></td>  <td class="Total"><input type="text" id="Total" readonly></td>  <td><button onclick="$(this).parent().parent().remove(); ">X</button></td></tr>');
  }
</script>
    </head>
<Body>
<input type="Button" value="Add More"onclick="AddMore()">
<table>
    <tr>
<th>Basic Amount</th>
<th>Quantity</th>
<th>Excise Duty</th>
<th>Sale Tax</th>
<th>VAT</th>
<th>Total</th>
<th>Remove</th>
</tr>
<tr det="product">
 <td class="Basic"><input type="text" id="Basic" usedToSum="true"></td>
 <td class="Quantity"><input type="number" id="Quantity" min="1" max="100" onchange="Data()"></td>
  <td class="Excise"><input type="text" usedToSum="true"></td>
  <td class="Sale"><input type="text" id="Sale" usedToSum="true"></td>
  <td class="VAT"><input type="text" id="VAT" usedToSum="true"></td>
  <td class="Total"><input type="text" id="Total" readonly></td>
  <td><button onclick="$(this).parent().parent().remove(); ">X</button></td>
</tr>
</table>
</Body>
</html>

Wednesday, 10 May 2017

Counting No. of Vowels,Consonant , Numbers, Symbols in a Entered String in java Script

<HTML>
   <head>
   </head>
   <Body>
      <canvas id="MyCanvas" height="300" width="300" style="Border:1px solid

red"></canvas>
<input type="button" value="->" onclick="Right()">
<input type="button" value="<-" onclick="Left()">
<input type="button" value="^" onclick="Up()" >
<input type="button" value="v" onclick="Down()">
   <script>

   x=0
  y=0
var c=document.getElementById("MyCanvas")
 var ctx=c.getContext("2d");
  ctx.fillRect(x,y,50,50);
        function Right()
          {
   if(x+50<c.width){
x=x+10;
ctx.fillRect(x,y,50,50);
 ctx.clearRect(0,0,x,y+50);
    }
           }
function Left()
          {
    if(x>0){
x=x-10;
ctx.fillRect(x,y,50,50);
 ctx.clearRect(x+50,y,10,50);
    }
           }
function Down()
          {
   if(y+50<c.width){
y=y+10;
 ctx.fillRect(x,y,50,50);
 ctx.clearRect(x,0,50,y);
  }
           }
function  Up()
          {
   if(y>0){
y=y-10;
 ctx.fillRect(x,y,50,50);
 ctx.clearRect(x,y+50,50,10);
  }
           }
document.onkeydown = function(e) {
    e = e || window.event;
    switch(e.which || e.keyCode) {
                        case 37:{Left();break;}
                        case 38:{Up();break;}
                        case 39:{Right();break;}
                        case 40:{Down();break;}        
              }
  }
   </script>
  </Body>
</html>