如何在codeigniter视图页面中使用javascript来生成onkeyup事件

I want to calculate qty*price from give input when price and qty changes automatically total should get changed using javascript events in codeigniter and total filed should be disabled my code is as follow

<script>
functionn caltotal()
{

}
</script>
<?php
echo form_open('add_veg/insert_data', 'class="form-horizontal" id="myform" role="form"');
$sales_date = array(
        'type'  => 'date',
        'name'  => 'date',
        'id'    => 'date',
        'class' => 'form-control'
);
$vegnames=array();
foreach($veg_names as $r){
   $vegnames[$r->value]=$r->label;
}
/*
$vegnames = array(
        'cauliflower' => 'Caulifower',
        'Brinjal' => 'Brinjal'
);
*/
$wt = array(
        'type'  => 'text',
        'name'  => 'weight',
        'id'    => 'wt',
        'class' => 'form-control'
);
$price = array(
        'type'  => 'text',
        'name'  => 'price',
        'id'    => 'price',
        'class' => 'form-control'
);

$total=array(
            'type'=>'readonly',
            'name'=>'total',
            'id'=>'total',
            'class'=>'form-control disabled'
);
$save=array(
        'name' =>'sub',
        'value' =>'Save',
        'class' =>'btn btn-success btn-sm'
);

echo form_label('Sales date', 'sdate', 'class="control-label col-sm-2"');
echo form_input($sales_date);
echo form_label('Vegitable Name', 'vname', 'class="control-label col-sm-2"');
//echo form_input($veg_name);
echo form_dropdown('v_name', $vegnames,'','class="form-control"');
echo form_label('Weight', 'wt', 'class="control-label col-sm-2"');
echo form_input($wt);
echo form_label('Price', 'price', 'class="control-label col-sm-2"');
echo form_input($price);
echo form_label('Total', 'total', 'class="control-label col-sm-2"');
echo form_input($total);
echo form_submit($save);
echo form_close();
?> 

Try this

$('#quantity').keyup(function() {
       var quantity = $("#quantity").val();
       var iPrice = $("#item_price").val();

       var total = quantity * iPrice;

       $("#total_price").val(total); // sets the total price input to the quantity * price
    });