0

I am having a form which can calculate the discounted price of what we addded in MRP input field. The number of rows can be increased by pressing a button.

Where the button appends the following code in the table

$("#add-book").click(function(){
    $(".books").append('<tr><td><select name="subject"><option disabled="" selected="">Subject</option><option>Microprocessors Microcontrollers</option><option>Compiler Design</option><option>Operating Systems</option><option>Artificail Intelligence</option><option>Web Engineering</option></select></td><td><input name="title" type="text" placeholder="Title of book..." maxlength="64"></input></td><td><input name="author" type="text" placeholder="Author..." maxlength="64"></input></td><td><input name="mrp" type="number" placeholder="MRP" maxlength="4"></input></td><td class="individual-noteshub-value"><input name="individual-noteshub-value" type="text" disabled=""  value="0"></input></td></tr>');
}

It gives the result for the first row but upon adding rows, It can not calculate the discounted price for proceeding rows.

The Js code for calculating, i am using is :

$(function(){
$('input[name="mrp"]').closest('td').find('input[name="mrp"]').on('input',function(){       

    $(this).closest('td').next().find('input[name="individual-noteshub-value"]').val($(this).val()/2);
});

$('input[name="pages"]').on('input',function(){     
    $(this).closest('td').next().find('input[name="individual-noteshub-value"]').val($(this).val()/4);
});

});

0 Answers0