jQuery - Creating changeable sequential numbers
<p>I am trying to build a simple form using jquery. By building a form I mean I am putting together the inputs ready to post based on buttons clicked. </p>

<p>So for example I have might have a variable like so...</p>

<pre><code>var1 = "&lt;input type='text' value='some product' /&gt;";
</code></pre>

<p>Which when clicking the associated button will append the html to more of the same. A bit like a shopping cart.</p>

<p>The problem I have is this, I need to number them in order so when an input is added to the list it creates the relevant index number so it would end up</p>

<pre><code>&lt;input id="number1" type="text" /&gt;
&lt;input id="number2" type="text" /&gt;
&lt;input id="number3" type="text" /&gt;
&lt;input id="number4" type="text" /&gt; etc etc...
</code></pre>

<p>Thats simple enough, I just used var = count++
The problem comes when I want to have the ability to remove an item from the list. I am removing them for the list using
$(this).parents('tr').remove();</p>

<p>BUT when you remove one from the middle of the list the numbers are not then sequential. So my question is how do I keep these numbers sequential. is it how I add the numbers in the first place or is there a way of "revisiting" previous instances of the count variable?</p>

<p>I cant really give an example of what Ive tried here as Im at a complete loss with it. I have scoured the internet and Im not really sure what is possible or not.</p>

<p>Im not being lazy here just looking for someone to provide a solution but if you could point me in the right direction that would be great.</p>
