title: How do I change the function of a button more than 2 times?
body: <p>I would like to make one button do 3 or more things one after the other. I'm trying to make a CYOA and I need one button to go through multiple layers/phases/sections(Start to layer 1 to layer 2) of the CYOA, with as little repeating code* as possible. I have placeholder text in the areas where the text in the title and the buttons go to see that the code runs properly</p>
  <p>*Example of repeating code</p>
  <pre><code>        function change_text(a){
              if (a == 1) {           
              document.getElementById(&quot;title&quot;).innerHTML = &quot;Phase 2&quot;;
              document.getElementById(&quot;button1&quot;).innerHTML = &quot;Ye&quot;;
              document.getElementById(&quot;button2&quot;).innerHTML = &quot;N&quot;;
              } else {
              document.getElementById(&quot;title&quot;).innerHTML = &quot;The End&quot;;
              }
          function change_text(a){
              if (a == 2) {           
              document.getElementById(&quot;title&quot;).innerHTML = &quot;Phase 3&quot;;
              document.getElementById(&quot;button1&quot;).innerHTML = &quot;Ye&quot;;
              document.getElementById(&quot;button2&quot;).innerHTML = &quot;N&quot;;
              } else {
              document.getElementById(&quot;title&quot;).innerHTML = &quot;The End&quot;;
              }
  </code></pre>
  <p>HTML</p>
  <pre><code>&lt;div id=&quot;centered&quot;&gt;&lt;h1 id=&quot;title&quot;&gt;Phase 1&lt;/h1&gt;
  &lt;button onclick=&quot;change_text(1)&quot; class=&quot;choice1&quot; id=&quot;button1&quot;&gt;Yes&lt;/button&gt;
  &lt;button onclick=&quot;change_text(2)&quot; class=&quot;choice1&quot; id=&quot;button2&quot;&gt;No&lt;/button&gt;&lt;/div&gt;
  </code></pre>
  <p>Javascript</p>
  <pre><code>        function change_text(a){
              if (a == 1) {           
              document.getElementById(&quot;title&quot;).innerHTML = &quot;Phase 2&quot;;
              document.getElementById(&quot;button1&quot;).innerHTML = &quot;Ye&quot;;
              document.getElementById(&quot;button2&quot;).innerHTML = &quot;N&quot;;
              } else {
              document.getElementById(&quot;title&quot;).innerHTML = &quot;The End&quot;;
              }
          }
  </code></pre>