Skip to content Skip to sidebar Skip to footer

Can Anyone Help Me With This Template That Is Getting The Weird Value In My Textbox

I have the following codes. Im using Django and using raw SQL statement to send data to my template for this part. views.py (SQL statement part) cursor = connection.cursor() tablen

Solution 1:

I try to rebuild your code. Now it works.

$(document).ready(function() {
  $('.chkcvalues').click(function() {
    var txt = ""
    $('.chkcvalues:checked').each(function(i, v) {
      txt += v.value + ","
    })
    txt = txt.substring(0, txt.length - 1)
    $('#txtvalues').val(txt);
  });
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<table class="table">
  <thead>
    <tr>
      <th>Interface registered</th>
      <th>Check to delete</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>TenGigabitEthernet1/0/5</td>
      <td>
        <div class="form-check">
          <input type="checkbox" value="{{item.0}}" class="chkcvalues">
        </div>
      </td>
    </tr>
    <tr>
      <td>TenGigabitEthernet1/0/6</td>
      <td>
        <div class="form-check">
          <input type="checkbox" value="{{item.1}}" class="chkcvalues">
        </div>
      </td>
    </tr>
    <tr>
      <td>TenGigabitEthernet1/0/7</td>
      <td>
        <div class="form-check">
          <input type="checkbox" value="{{item.2}}" class="chkcvalues">
        </div>
      </td>
    </tr>
  </tbody>
</table>
Checkbox-Value: <input type ="text" name="deleteint" id="txtvalues" >

Solution 2:

I had to correct txt+=$(this).val(txt) + "," to txt+=$(this).val() + "," and it worked perfectly


Post a Comment for "Can Anyone Help Me With This Template That Is Getting The Weird Value In My Textbox"