无法使用jQuery获取文本字段值

我有一个invoice.jsp页面,我必须使用jQuery在文本框中计算一些值。

在我的发票中有一个数量文本框。 如果用户输入数量,则应动态计算计算出的价格,即(total_subPrice= unit_price * quantity)并显示在另一个名为“price”的文本框中。

现在我的当前输出是这样的: 在此处输入图像描述

我尝试了下面的代码来解决这个问题,但我的jQuery代码无法获取unitprice文本字段数据。 我不知道为什么。 请检查下面的代码,并为我建议一个解决方案。

invoice.jsp

 -------------------- --------------------  $(document).ready(function(){ $(function() { $('input[name^="quantity"]').change(function() { var unitprice = $(this).siblings('input[name^="unitprice"]').val(); alert("Unit price check="+unitprice); //problem in this line. Unable to get the unit price $(this).siblings('input[name^="price"]').val($(this).val() * unitprice); }); }); });  .............................. .............................. <!-- Here I am iterating through a list from my dabase using strus2 framework tags. And defined my input field values in struts2 tag eg. `` is the same as ` -->  
................................ ................................

当我更改数量文本框中的任何值时,我的警告框显示“单价检查=未定义”。 请检查我的代码并建议任何解决方案。

更新:生成的HTML

  inside loop {  book title display           

我得到了它的工作: http : //jsbin.com/efinak/2/edit

 $(function() { $('input[name="quantity"]').change(function() { var unitprice = $(this).parents('tr').find('input[name="unitprice"]').val(); $(this).parents('tr').find(' input[name="price"]').val($(this).val() * unitprice); }); });