How to add form iside Datatable?
How to add form iside Datatable?
aadesh
Posts: 1Questions: 1Answers: 0
Hello,
I am new to html and I am trying to add a form with a submit button in each row inside datatable. However, I am unable to perform submit action while clicking the button on the row. Please find the below code that I am trying to use:
<table id="example" class="dataTable" aria-describedby="example_info">-->
<thead><tr><th>XXXXXX</th><th>XXXXXX</th><th>XXXXXX</th><th>XXXXXX</th><th>XXXXXX</th></tr></thead>
<tbody>
{%for i,j,l,k in xxxx%}
<form class="name" action ="{%url 'xxxx_xxxx:yyyy' %}" method="post">
{% csrf_token %}
{% if k == 'zzzzz' %}
<tr><td><input type="hidden" name="aaaaa" value={{i}}>{{i}}</td><td>{{j}}</td><td>{{l}}</td><td><input type="hidden" name="sssss" value={{k}}>{{k}}</td><td><input type="submit" value="submit"class="btn_submit" /></td></tr>
{% else %}
<tr><td><input type="hidden" name="aaaaa" value={{i}}>{{i}}</td><td>{{j}}</td><td>{{l}}</td><td><input type="hidden" name="ssss" value={{k}}>{{k}}</td><td><input type="submit" value="submit"class="btn_submit" /></td></tr>
{%endif%}
</form>
{%endfor%}
</tbody>
</table>
<script type="text/javascript" charset="utf8" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.2.min.js"></script>
<script type="text/javascript" charset="utf8" src="http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/jquery.dataTables.min.js"></script>
<script>
$(function(){
$("#example").dataTable();
})
</script>
Any help on this would be deeply appreciated!
This discussion has been closed.
Answers
Can you provide a bit more information on what you are trying to accomplish? Perhaps if we have a better understanding of what you are trying to do we can help.
Also, take a look at: https://datatables.net/examples/api/form.html to see if this could possibly answer some of your questions.