0

I have no idea how can I solve my problem. I have Django template with two models. I put these models in inlineformset_factory.

Example

DhcpConfigFormSet = inlineformset_factory(Dhcp, IPRange, extra=1)

and I displayed this form in template like this pictures

form http://sphotos-h.ak.fbcdn.net/hphotos-ak-prn1/601592_10151469446139596_1335258068_n.jpg

I want implement event, when I click on plus stick (marked field on pictures), show one more row (ip initial field, ip final field and delete check box).

I tried to do it on this way :

$(document).ready(function() {
        $(".plusthick-left").click( function() {
          var tr= $(".sort-table").find("tbody tr:last").length;
               $(".sort-table").find("tbody tr:last").after($(".sort- table").find("tbody tr:last").clone())
      });     

but I have problem, because I just made copy of last row and took same attributes values?

My question is : How can I make new row, and set all attributes with values of last row increased by one.

For example:

<input type="text" id="id_ip_initial_0_ip_range">

This is field that generated form in template, and I want make field with id value like this:

<input type="text" id="id_ip_initial_1_ip_range">

How can I do it? :)

karthikr
  • 97,368
  • 26
  • 197
  • 188
prog.Dusan
  • 1,324
  • 2
  • 12
  • 25

0 Answers0