title: How to make HTML form fields automatically change when an option selected on a select field
body: <p>Let's say I have a form like this in my CodeIgniter project.</p>
  
  <pre><code>&lt;?php echo form_open(); ?&gt;
      &lt;select&gt;
          &lt;?php foreach($status_list as $status): ?&gt;
          &lt;option value="&lt;?php echo $status-&gt;id; ?&gt;"&gt;&lt;?php echo $status-&gt;name; ?&gt;&lt;/option&gt;
          &lt;?php endforeach; ?&gt;
      &lt;/select&gt;
      &lt;!-- Show this only if status type is, let's say "E" --&gt;
      &lt;input type="text" name="E_happened"&gt;
      &lt;!-- Show this only if status type is, let's say "S" --&gt;
      &lt;input type="text" name="S_happened"&gt;
  &lt;?php echo form_close(); ?&gt;
  </code></pre>
  
  <p>What I want to do is if an user select one status, according to the it's type, show a text field to get an input. </p>
  
  <p>I've made a way to get a type of the status like this: <a href="http://localhost/myapp/index.php/status/type/" rel="nofollow">http://localhost/myapp/index.php/status/type/</a>{status_id} where users can pass status ID and it will "echo" the type of the status. </p>
  
  <p>I want to receive it back to the HTML page via a JavaScript method and show those text input fields. How do I do that?</p>
  
  <p>Thank you. :)</p>