title: Persist actions after button onclick() : JavaScript
body: <p>I've the following initial structure:</p>
  
  <pre><code>PrimaryLabel: 'Drop-Down' [Add Button]
  </code></pre>
  
  <p>Once I click on the Add button, Another <code>Label: 'Drop-Down' [Add Button]</code> must be displayed :: That's the requirement. Maximum such lines? => 5</p>
  
  <pre><code>PrimaryLabel: 'Drop-Down' [Add Button]
  Label: 'Drop-Down' [Add Button]
  </code></pre>
  
  <p>I've set all labels', Drop-downs' and Button' [other than primary] <code>display</code> property to <code>none</code>.</p>
  
  <p>I've the following javascript:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
              function add(currBtnId,nextDdId, nextBtnId, event){
                  event.preventDefault();
                  console.log(currBtnId, nextBtnId, nextDdId);
                  document.getElementById(currBtnId).disabled = true;
                  $('#'+nextBtnId).show();
                  if (nextDdId!=null) {
                      $('#'+nextDdId).show();
                  }
              }
          &lt;/script&gt;
  </code></pre>
  
  <p>Here's how my button looks like:</p>
  
  <pre><code>&lt;h:button type="button" value="ADD" class="add-btn" id="current-btn-id" onclick="add('current-btn-id', 'some-drop-down-id', 'next-btn-id', event)"/&gt;
  </code></pre>
  
  <p>This is how it looks like after inspect-element:</p>
  
  <pre><code>&lt;input id="add-btn1" type="button" onclick="add('add-btn1', 'reqpanel1', 'add-btn2', event); window.location.href='/project-name/page-name'; return false;" value="ADD" class="add-btn"&gt;
  </code></pre>
  
  <p><strong><em>Problem:</em></strong></p>
  
  <p>After I click the Add button, the next label, drop-down and Add buttons show, but <strong>only for a second</strong>. It goes back to the initial state almost immediately.
  What should I do now?</p>
  
  <p>I think the problematic part is: <code>window.location.href='/project-name/page-name';</code></p>
  
  <p>How do I get rid of it? It reloads every time the button is clicked.</p>