'inlineformsetfactory jquery add value in table row
Below is my output and i want to add some data values in second line of table how can I get it from my below jscript. please help me out on this.
I am able to add next row and can save data if i entered it manually, however i need to get data from prefilled.
<div>
<h2>Receipt</h2>
<hr>
<form action="" method="post" enctype="multipart/form-data">{% csrf_token %}
{% for field in form.visible_fields %}
{{ field.label_tag }}
{{ field.errors }}
{{ field }}
{{ field.help_text }}
{% endfor %}
<table class="w3-table-all" style="width:100%">
{{ paymentdetail.management_form}}
{% for form in paymentdetail.forms %}
{% if forloop.first %}
<thead>
<tr>
{% for field in form.visible_fields %}
<th>{{ field.label|capfirst }}</th>
{% endfor %}
</tr>
</thead>
{% endif %}
<tr class="{% cycle row1 row2 %} formset_row">
{% for field in form.visible_fields %}
<td>
{# Include the hidden fields in the form#}
{% if forloop.first %}
{% for hidden in form.hidden_fields %}
{{ hidden }}
{% endfor %}
{% endif %}
{{ field.errors.as_ul }}
{{ field }}
</td>
{% endfor %}
</tr>
{% endfor %}
</table>
<input class="w3-btn w3-blue" type="submit" value="Save"/> <a href="{% url 'profile-list' %}">back to the list</a>
</form>
</div>
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="{% static 'formset/jquery.formset.js' %}"></script>
<script type="text/javascript">
$('.formset_row').formset({
addText: 'add another more',
deleteText: 'remove',
prefix: '{{ paymentdetail.prefix}}',
});
</script>
{% endblock %}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
