I have a form that contains input elements whose name is in the array notation e.g.: <input name="example[news][1]" .../> <input name="example[news][2]" .../> ...
I use jQuery to dynamically add new input elements to the dom by copying the previous element. However, that leaves me with the following: <input name="example[news][1]" .../> <input name="example[news][2]" .../> <input name="example[news][2]" .../> ... I want the last number in the array notation to add to the previous one, so it SHOULD BE: <input name="example[news][1]" .../> <input name="example[news][2]" .../> <input name="example[news][3]" .../> ... How can I do this easily with jQuery? Ideally it should read the number of the last array, add one up to it and then display that in the form.

