2014-05-03 47 views
0

我想获取其质量已更改的元素的当前价格。 我只是能够改变第一个元素的价格,但不是其他 请帮助我从数量的下拉菜单中获取所选元素的数量。从for循环生成的td标记中获取输入标记的值

<script type="text/javascript"> //quantity retrival 
    $(document).ready(function() { 

    $('.quantityx').change(function(){ 
     alert("message"); 

     var tot =$('#pricexx').val()* this.value; 
     alert(this.parent.find('input[name=pricexx]').val()); 

     }); 

    }); 
    </script> 

    <table id="mytable"> 

        <% 
         int i = 0; 
         while (it.hasNext()) { 
          i++; 
          Product_List PL = (Product_List) it.next(); 

          list.add("" + PL.getProduct_id()); 
          String order = list.toString(); 
          session.setAttribute("orders", order); 
        %><tr class="row"> 



         <td class="delete"> 
          <div class="centererer"> 
           <form action="PDelete" method="get"> 
            <input type="hidden" name="p_id" value="<%=PL.getProduct_id()%>" 
             id="Product_id" /> <input type="submit" class="close"> 
           </form> 
          </div> 
         </td> 
         <td class="image"><img src="<%=PL.getImage()%>" width="86" 
          height="86" /></td> 
         <td class="name"><%=PL.getBrand()%> <%=PL.getDetail()%></td> 
         <td class="size"><%=PL.getCloth_size()%></td> 

         <td class="price">&#8377;<input name="pricexx" type="text" disabled="disabled" value="<%=PL.getPrice()%>"></td> 
         <td class="quauntity"> 
         <select class="quantityx"> 
       <option value="1" selected="selected">1</option> 
       <option value="2">2</option> 
       <option value="3">3</option> 
       <option value="4">4</option> 
       <option value="5">5</option> 
      </select> 


          </td> 
         <%!int totalprice, netprice = 0,quant=1;%> 
         <% 
          totalprice = quant * PL.getPrice(); 
         %> 
         <% 
          netprice = totalprice + netprice; 
         %> 

         <td class="price">&#8377;<input id="tp" type="text" disabled="disabled" value="<%=totalprice%>"></td> 

        </tr> 
        <% 
         } 
        %> 
       </table> 
       <!--   --> 
       <input type="hidden" value="<%=list.toString()%>" name="array" /> <br /> 
       <br /> 
       <br /> 
       <br /> 
       <table> 
        <tr> 
         <!-- <td class="size"></td> --> 
         <td class="total">TOTAL <span class="pricex">&#8377;<%=netprice%></span></td> 


        </tr> 
       </table> 

回答

0

您的选择器对于获取当前input[name=pricexx]是不正确的。你应该这样做

var input = $(this).parent().parent().find('input[name=pricexx]'); 
var tot = input.val() * this.value; 
+0

谢谢..它的工作! – vaibhav