Calculate percentage using jQuery in php

<script type="text/javascript">

function calpercentge(e)

{

    

    var pcnt=6;

    var nprice=0;

    var spval= e.value;  

    

    if(spval == 'NaN' || spval == "") {

        spval = 0.00;

        document.getElementById("product_price").value = spval.toFixed(2);

    } else {   

        spval = parseFloat(spval); 

        pcnt = parseFloat(pcnt); 

        var pcnt_rs = parseFloat( parseFloat( spval*pcnt )/100 );

        nprice = parseFloat(spval + pcnt_rs);

        document.getElementById("product_price").value = nprice.toFixed(2);

  }

}

</script>

<!-- -->




<script>

    $(function () {

        $("#price").on('keyup change',function(){

            calpercentge(this);

        });

    });

</script>