これはすべてクライアント側のリクエストのようですので、 jQueryを使用して問題を解決することをお勧めします。私の例で使用するすべての関数は、そのサイトで見つけることができます。スタックオーバーフローには、すべての疑問を解決するための例がたくさんあります。質問に移ります:
1. ご希望の結果が得られませんでしたが、クリック イベントを使用して addRow ボタンでイベントを生成する必要があります。
$('AddRow').click(function(e){
e.preventDefault(); //this avoid the default button action (submit/send)
var last_id = $('row').last().attr('id'); //retrieve the id of the last added row you probably will have to strip/transform it since id shouldn't be only number
$('row').last().append('insert here html with form fields of the new row with the (last_id+1)');
});
2. UnitPrice を取得するには、ajax呼び出しを使用し、anを使用し$('product').change(function(){});
てイベントをトリガーし、結果を ajax 経由で取得します。そのフィールドに入力するとすぐに、単純な jquery/javascript 関数を使用して、Quantity フィールドに基づいて合計価格を動的に計算できます。
$('Quantity').change(function(){
//add here control to check if fields are empty/wrongly set
var UnitPrice = parseFloat($('UnitPrice').val());
var Quantity = parseInt($('Quantity').val());
$('TotalPrice').val(UnitPrice*Quantity);
})