2013-02-15 21 views
0

我面临使用jquery appendo插件的问题,我已经克隆了字段,但是我想根据从下拉列表中选择的内容填充文本字段,我有一个下拉列表的产品,当我选择一个,它旁边的文本字段必须填写相应的比率。我能够通过更改从服务器端带来数据的下拉列表来激活ajax事件,但我无法填充相邻的文本字段。这是我的代码。jquery appendo插件

<script type="text/javascript" lang="javascript" src="jquery-1.8.2.min.js" ></script> 
<script type="text/javascript" lang="javascript" src="jquery.appendo.js" ></script> 
<script type="text/javascript" lang="javascript"> 
    $(document).ready(function(){ 

     $('.product').change(function(){ 
      //ajax call and receiving the data but after getting the data from server how to populate the rate text field 
     }); 
     var id = 0; 
     var append = $('#objid').appendo({ 
     allowDelete: true, 
     copyHandlers: true  
    }); 


}); 
</script> 

这是我的html零件。

<body> 
    <form action="#" method="post"> 
    <table id="objid"> 
     <thead> 
      <tr> 
       <th>Client:</th> 
       <th>Product:</th> 
       <th>Rate:</th> 
      </tr> 
     </thead> 
     <tr><td><input type="text" name="name[]"></td> 
     <td> 
      <select class="product" name="product[]"> 
       <option value="">---Select---</option> 
       <option value="web_designing">Web Designing</option> 
       <option value="hosting">Hosting</option> 
       <option value="domain">Domain</option> 
      </select> 
     </td> 
     <td><input type="text" name="rate[]" id="rate[]"/></td> 
     </tr> 

    </table> 
    <br> 
    <input type="submit" value="Submit" name="submit"> 
    </form> 
</body> 

回答

0

在代码的一部分:

$('.product').change(function(){ 
     //ajax call and receiving the data but after getting the data from server how to populate the rate text field 
    }); 

您可以通过使用此代码增加价值的文本字段:

$('.product').change(function(){ 
     //ajax call and receiving the data but after getting the data from server how to populate the rate text field 
     var value = ajax_received_value; 
     var $this = $(this); 
     $this.parent().next().children().val(value); 
    });