如何在MVC中追加附加行中的2个数字 [英] How to multiply 2 numbers in appended row in MVC

查看:68
本文介绍了如何在MVC中追加附加行中的2个数字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的朋友们,



我需要在网格中将2个输入框值相乘,并在第3个输入框中显示结果。我正在使用课堂进行按键活动。



它适用于网格。但是当我添加行并将行追加到网格时输入框按键不起作用。



网格文本框如下:@ Html.TextBox(Qty_Req_+( int)item.Id,(decimal)item.QtyRequested,new {@ class =QtyReq,@ style =display:none}







谢谢和问候,

Vivek .R

软件工程师。



我尝试过:



添加行或追加:



var tr ='< input id ='+ Item_Name +'type =textclass =ItemName ItemNames/> < ; button id =btnOktype =buttonclass =btn btn-primary btn-xs> ..< / button>'+

'< input id ='+ ItemR_Code +'type =textclass =IRCode/> '+

'< input id ='+ Item_Code +' type =textclass =ItemCodedisabled =disabled/> '+

'<输入id ='+ Unit_Price +'type =textclass =UnitPricedisabled =disabled/> '+

'< input id ='+ Qty_Req +'type =textclass =QtyReq/> '+

'< input id ='+ Total +' type =textclass =Totaldisabled =disabled/> '+

'保存 取消'

'';



$(#grid tbody)。append(tr);



javascript:



Dear Friends,

I need to multiply 2 input box values in grid and shows result in 3rd input box. am using class for keypress event.

It works on grid. but when i add rows and append rows to grid that input box keypress didn't works.

Grid textbox like this: @Html.TextBox("Qty_Req_" + (int)item.Id, (decimal)item.QtyRequested, new {@class="QtyReq", @style = "display:none" }



Thanks & Regards,
Vivek .R
Software Engineer.

What I have tried:

Add row or Append :

var tr = ' <input id="' + Item_Name + '" type="text" class="ItemName ItemNames" /><button id="btnOk" type="button" class="btn btn-primary btn-xs">..</button>' +
' <input id="' + ItemR_Code + '" type="text" class="IRCode" />' +
' <input id="' + Item_Code + '" type="text" class="ItemCode" disabled="disabled"/>' +
' <input id="' + Unit_Price + '" type="text" class="UnitPrice" disabled="disabled"/>' +
' <input id="' + Qty_Req + '" type="text" class="QtyReq" />' +
' <input id="' + Total + '" type="text" class="Total" disabled="disabled" />' +
' Save Cancel' +
'';

$("#grid tbody").append(tr);

javascript:

$('input[class="QtyReq"]').keyup(function () {
       $(this).addClass('selected').siblings().removeClass('selected');
       var unitprice = $(this).closest("tr").find('.UnitPrice');
       var qtyreq = $(this).closest("tr").find('.QtyReq');
       var total = $(this).closest("tr").find('.Total');
       total.val(unitprice.val() * qtyreq.val());

   });

推荐答案

(#grid tbody)。append(tr);



javascript:



("#grid tbody").append(tr);

javascript:


' input [class =QtyReq]') .keyup( function (){
('input[class="QtyReq"]').keyup(function () {


this )。 addClass(' selected')。siblings()。removeClass(' 选中');
var unitprice =
(this).addClass('selected').siblings().removeClass('selected'); var unitprice =


这篇关于如何在MVC中追加附加行中的2个数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆