title: Using onclick with selection to load textarea content from mysql db in codeigniter
body: <p><a href="https://i.stack.imgur.com/UqlNc.png" rel="nofollow noreferrer">The content shows but the selection option remains the same</a>I'm considerably new to code igniter and I've been trying to set up a selection form so that when an option has been selected, the content would be loaded from the db (mysql). I've got most of it down already but the only problem is with the select section. The content shows when an option is selected but the selection area doesn't reflect the option shown. It shows the default. Here's the view:</p>
  
  <pre><code>    &lt;form accept-charset='utf-8' action="&lt;?php echo base_url() ?&gt;note/def_messages" method='GET'&gt;
                          &lt;label for='msg_types'&gt;Select one the default message types:&lt;/label&gt;
                          &lt;select id='msg_types' name='msg_types' onchange="this.form.submit()"&gt;
                                  &lt;option selected id="Templates" &gt;Please select message type ...&lt;/option&gt;
                                  &lt;option value = "Qbalance"&gt;Quarterly Balances&lt;/option&gt;&lt;br&gt;
                                  &lt;option value = "Felicitations"&gt;Felicitations&lt;/option&gt;&lt;br&gt;
                                  &lt;option value = "Birthday"&gt;Birthday&lt;/option&gt;&lt;br&gt;
                                  &lt;option value = "Contributions"&gt;Contributions&lt;/option&gt;&lt;br&gt;
                                  &lt;option value = "News"&gt;News&lt;/option&gt;
                              &lt;/select&gt;&lt;br&gt;&lt;br&gt;
  
                              &lt;div class="alert alert-success"&gt;
  &lt;textarea id="messages" rows = "7" cols = "120" style="text-align:'left'" placeholder = "Blah Blah Blah ..."&gt;&lt;?php if (isset($result)){foreach($result as $row){echo  trim(stripslashes(htmlentities($row['message'])));}
                                      }else{
                                         echo "Nothing has been selected";
                                      }
                                  ?&gt;&lt;/textarea&gt;&lt;br&gt;&lt;br&gt;
                                  &lt;button type="submit" class='btn btn-primary btn-lg' data-toggle="modal" data-target="#myModal"&gt;Send&lt;/button&gt;
                          &lt;/form&gt;
  </code></pre>
  
  <p>Here's the Controller part:</p>
  
  <pre><code>function def_messages(){
      $data = Array();
      $types=$this-&gt;input-&gt;get('msg_types');
  
      //echo $types;
  
      $data['result'] = $this-&gt;db-&gt;query("SELECT message FROM messages WHERE msg_name = '$types'")-&gt;result_array();   
      $data['msg_type'] = $types;
  
      $this-&gt;load-&gt;view('notifications', $data);  
  }
  
  
  
  
       public function index($page='notifications'){ 
          if (!file_exists(APPPATH.'views/'.$page.'.php')){
              show_404();
          }else{
              $this-&gt;load-&gt;view($page);
          }
       }
  </code></pre>