jquery / learn.jquery.com

jQuery Learning Center web site content
https://learn.jquery.com
Other
924 stars 487 forks source link

jquery passing value #761

Closed surajchouhan262 closed 7 years ago

surajchouhan262 commented 7 years ago
<div id="defect-grid" class="grid-view">
  <table class="items table" style="table-layout:fixed; width:100%">
   <thead>
     <tr>
     <th style="background-color:#2e6e9e; color:white; width:25%;">Material Description</th>
     <th style="background-color:#2e6e9e; color:white; width:20%;">Material Category</th>
     <th style="background-color:#2e6e9e; color:white; width:20%;">Barcode</th>
     <th style="background-color:#2e6e9e; color:white; width:15%;">Quantity</th>   
     <th style="background-color:#2e6e9e; color:white; width:20%;">Action</th>                                   
  </tr>
</thead>
<tbody class="add-item">
<tr>
<td>SPRAYMATE TIN ENAMEL RICH PALE 250ML GLD</td>
  <td>Aerosols</td>
  <td>13606</td>
  <td><input id="362" class="quantity-sec" onchange="javascript:return setTextVal(this.id,this.value)" type="text"></td>
  <td> <a id="btnAddMaterial" style="padding:0px 32px" class="btn btn-success add-btn">Add</a></td>
  </tr>
 </tbody>
</table>
</div>
<div style="color:blue; padding: 10px 0px 10px 0px; font-size:16px;  font-weight:bold;">Add Material List</div>
<div id="material-grid" class="grid-view">
 <table class="items table" style="table-layout:fixed; width:100%">
   <thead>
    <tr>
    <th style="background-color:#2e6e9e; color:white; width:25%;">Material Description</th>
     <th style="background-color:#2e6e9e; color:white; width:20%;">Material Category</th>
     <th style="background-color:#2e6e9e; color:white; width:20%;">Barcode</th>
     <th style="background-color:#2e6e9e; color:white; width:15%;">Quantity</th>
     <th style="background-color:#2e6e9e; color:white; width:20%;">Action</th>
   </tr>
 </thead>
 <tbody class="preview-item">
 <!-- <tr>
  <td>SPRAYMATE TIN ENAMEL RICH PALE 250ML GLD</td>
   <td>Aerosols</td>
   <td>13606</td>
   <td>3</td>
   <td> <a id="201" style="padding:0px 32px" class="btn btn-success remove-field" onclick="javascript:return setRemoveVal(this.id)">Remove</a></td>
</tr> -->
</tbody>
</table>
</div>
<p>and my jquery code is:-</p>
<script>
var x = 0;
 $(document).ready(function(){
  var max_input = 10;
  var wrapper = $('.add-item');
  var add_field = $('.add-btn');
  $(add_field).click(function(s) {
    s.preventDefault();
    if(x < max_input) {  
      x++; 
      $('.preview-item').append('<tr class="tr-remove"><td>SPRAYMATE TIN ENAMEL RICH PALE 250ML GLD</td><td>Aerosols</td><td>13606</td><td><p id="365"></p></td><td> <a id="btnAddMaterial" style="padding:0px 32px" class="btn btn-success remove-field">remove</a></td></tr>');//add input box
    }
  })

  $('.preview-item').on("click", ".remove-field", function(s){ 
    s.preventDefault();
    var min_input = 0;
    if(x > min_input) {
      $('.tr-remove').eq(0).remove();
      x--;
    }
  })
})
</srcipt>
surajchouhan262 commented 7 years ago

i need help please correct this code

dmethvin commented 7 years ago

https://stackoverflow.com