title: JQuery Steps - calculating number of steps (as they change dynamically) so that I can insert/remove at specific point
body: <p>I've recently built a funeral cost calculator tool for a client using Jquery Steps.</p>
  
  <p>The tool's form is quite complex, as a number of steps depend on whether certain form options have been selected.</p>
  
  <p>I managed to accommodate this myself by using the "insert" and "remove" methods triggered "onchange" of the radio buttons. When the user selects that a death has occurred, there are 7 steps. When a user selects that a death has <em>not</em> occurred, there are 5 steps (see images attached). (See below for some sample code)</p>
  
  <p><a href="http://postimg.org/image/n50tn18ph/" rel="nofollow">No death occurred (screenshot)</a></p>
  
  <p><a href="http://postimg.org/image/bhzexqf9l/" rel="nofollow">Death Occurred (screenshot)</a></p>
  
  <p>The steps are inserted and removed at index 4. If a user toggles back and forth between the options, it will insert the 2, then remove the 2, insert the 2, then remove the 2, etc. I found this was simple enough.</p>
  
  <p>Trouble came when further into the form I needed to apply a similar condition. However, I found that I couldn't specifically target an index to insert or remove at because I couldn't predict how many steps there were at this point (as it is based on the user's previous selection - see above).</p>
  
  <p>My javascript knowledge is limited, so I'm at a loss. I know the logic needed to make it work, I just don't know how to implement it.</p>
  
  <p>I want to know how I can use javascript/jquery to count the number of steps (in order to target the last step) and target the current step. Unless of course there's a simpler or better method that somebody can suggest.</p>
  
  <p>I've been racking my brains over this, any help would be appreciated. Thank you!</p>
  
  <pre><code>&lt;input type="radio" name="deathOccurred" rel="death-occured-yes" value="Yes"  class="required" onclick="calculateTotal()" onchange="$('#estimator-form').steps('insert', 4, {
      title: 'Clergy/Celebrant',
      content: '&lt;STEP HTML HERE&gt;'
  });
  $('#estimator-form').steps('insert', 5, {
  title: 'Other options',
  content: '&lt;STEP HTML HERE&gt;'
  /&gt; Yes &amp;nbsp;&amp;nbsp;
  &lt;input type="radio" name="deathOccurred" rel="death-occured-no" value="No" checked  onclick="calculateTotal()" onchange="$('#estimator-form').steps('remove', 5, {});  $('#estimator-form').steps('remove', 4, {});" /&gt; No
  </code></pre>