Skip to content

jquery passing value #761

Closed
Closed
@surajchouhan262

Description

@surajchouhan262
<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>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions