title: How to Pass data from table data to pop-up modal (Using Yii Framework)
body: <p>How can i pass data from my table to a pop-up.
  This is how i did it in my table:
  I populate the table from my database using controllers and models</p>
  
  <pre><code>    &lt;table class="table table-striped table-checkable" id="demo-dtable-02" aria-describedby="DataTables_Table_0_info"&gt;
          &lt;thead&gt;
              &lt;tr&gt;
                  &lt;th class="sorting" role="columnheader" tabindex="0" aria-controls="DataTables_Table_0" rowspan="1" colspan="1" aria-label="Subject: activate to sort column ascending" style="width: 220px;"&gt;??&lt;/th&gt;&lt;th class="sorting" role="columnheader" tabindex="0" aria-controls="DataTables_Table_0" rowspan="1" colspan="1" aria-label="Date: activate to sort column ascending" style="width: 79px;"&gt;??&lt;/th&gt;
              &lt;/tr&gt;
          &lt;/thead&gt;
          &lt;tbody role="alert" aria-live="polite" aria-relevant="all"&gt;
  
              &lt;?php
                      foreach ($my_page_data['text_list']as $text_list_key =&gt; $text_list_data){
              ?&gt;
  
              &lt;tr class="odd"&gt;
                  &lt;td class=" "&gt;&lt;a href="#" onclick="viewText(&lt;?php echo $text_list_data['id'] ?&gt;)" data-toggle="modal" data-target="#view-text" &gt;&lt;?php $msg = $text_list_data['msg']; ?&gt;&lt;/a&gt;&lt;/td&gt;
              &lt;div id="&lt;?php echo $inbox_list_data['id'] ?&gt;" data-content="&lt;?php $msg = $inbox_list_data['message']?&gt;"&gt;&lt;/div&gt; &lt;!-- i used this as a hidden div for the data to be passed because i dont know other ways --&gt;                                                                          
                  &lt;td class=" "&gt;&lt;?php $date =  $text_list_data['date_updated'];?&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;?php } ?&gt;
          &lt;/tbody&gt;
      &lt;/table&gt;
  </code></pre>
  
  <p>Then i used a script to pass the data...</p>
  
  <pre><code>    &lt;script&gt;
          function viewInbox(id){
              $('#inbox-message-body').text($('#'+id).attr('data-content'));
          }
      &lt;/script&gt;
  </code></pre>
  
  <p>And then the the clicked data will be displayed here:</p>
  
  <pre><code>    &lt;div class="modal-body"&gt;
          &lt;div class=" . . ."&gt;
              &lt;div class=".."&gt;
                  &lt;span class="view-label"&gt;From:&lt;/span&gt; MY OTHER DATA &lt;!--TODO: --&gt;
                  &lt;br&gt;
                  &lt;span class="view-label"&gt;To:&lt;/span&gt; MY DATA&lt;!--TODO: --&gt;
                  &lt;br&gt;
              &lt;/div&gt;
  
          &lt;/div&gt;
              &lt;!--TODO: Message body--&gt;  I
         &lt;span id="message-body" class="span8"&gt;&lt;/span&gt; 
  
      &lt;/div&gt;
  </code></pre>
  
  <p>This code are just in one file.
  The page im creating is like. I have a table of messages. Then to view message is to click it and a pop-up will appear.</p>
  
  <p>Any insights?</p>
  
  <p>Your help is greatly appreaciated.</p>