title: Show alert with the content of a Database selection
body: <p>I am very new to JavaScript what is related to it. </p>
  
  <p>I have a set of dynamic rows and corresponding columns to those rows. In one column I have a button. When I click on it, it displays the results of a <code>select</code> query in another page based on the <strong>Posted Competence_ID</strong>.</p>
  
  <p>The query works fine and I get correct results when I click on the button. However, what I would like to do now, is to display that message in <strong>an alert</strong> when the button is clicked and stay on the same page rather than opening a new tab..</p>
  
  <p>Here is the relevant HTML code that shows the table I use:</p>
  
  <pre><code>echo "&lt;table border='1' id='mycompstable' class='sortablee' cellpadding='0' cellspacing='0'&gt;";
  echo "&lt;tr&gt;&lt;th&gt;ID&lt;/th&gt;&lt;th&gt;Competence Group&lt;/th&gt;&lt;th&gt;Competence Class&lt;/th&gt;&lt;th&gt;Competence Description&lt;/th&gt;&lt;th&gt;Own Evaluation&lt;/th&gt;&lt;th&gt;Manager's evaluation from last year&lt;/th&gt;&lt;th&gt;Target levels&lt;/th&gt;&lt;th&gt;Gap&lt;/th&gt;&lt;th&gt;Action&lt;/th&gt;&lt;th class='unsortable'&gt;Action ready target &lt;/th&gt;&lt;/tr&gt;";
  
  foreach($descs as $compi){  
      echo "&lt;tr&gt;";
          echo "&lt;td&gt;".$compi['Competence_ID']."&lt;/td&gt;";
          echo "&lt;td&gt;&lt;p style='text-align: center;'&gt;".$compi['Competence_Group']."&lt;/p&gt;&lt;/td&gt;";
          if(isset($compi['Competence_class'])){echo "&lt;td&gt;".$compi['Competence_class']."&lt;/td&gt;";}else echo "&lt;td&gt;&lt;p style='text-align: center;'&gt;-&lt;/p&gt;&lt;/td&gt;";
          echo "&lt;td&gt;".$compi['Competence_Description']."&lt;/td&gt;";
          echo "&lt;td class='evaluation'&gt;";
              echo "&lt;select class='ownlevelselect' id='ownlevelselect-.".$compi['Competence_ID']."' name='level-".$compi['Competence_ID']."' &gt;";
                 if (isset($compi['ownlevel']) &amp;&amp; $compi['ownlevel']!= '' &amp;&amp; !empty($compi['ownlevel']) &amp;&amp; $compi['ownlevel']!= 0) {
                    echo "&lt;option selected value='".$compi['ownlevel']."' selected='selected'&gt;".$compi['ownlevel']."&lt;/option&gt;";
  
                  }
                  echo "&lt;option value='' &gt;--&lt;/option&gt;";
                  echo "&lt;option value='1'&gt;1&lt;/option&gt;&lt;option value='2'&gt;2&lt;/option&gt;&lt;option value='3'&gt;3&lt;/option&gt;&lt;option value='4'&gt;4&lt;/option&gt;&lt;option value='5'&gt;5&lt;/option&gt;";
              echo "&lt;/select&gt;";
              echo $compi['ownlevel'];
  
  
              echo '&lt;a test="'.$compi['Competence_ID'].'" onClick="showLevels('.$compi['Competence_ID'].');" target="_blank" href="'.INDEX.'?categ='.$_GET['categ'].'&amp;action='.$_GET['action'].'&amp;subaction=viewlevels'.'&amp;levels='.$compi['Competence_ID'].'"&gt;';
              echo '&lt;img class="linkki" src="'.KUVAT.'paivita.gif" alt="'._("tiedot").'" title="'._("Click to view the description of each level?").'"/&gt;&lt;/a&gt;';
          echo "&lt;/td&gt;";
  </code></pre>
  
  <p>Here is the code to retrieve the data:</p>
  
  <pre><code>    function fetchlevels($Competence_id){
      $this-&gt;query="SELECT * FROM levels WHERE comp_id=".$_REQUEST['levels'];
      $tulos=$this-&gt;suoritaKysely();
      return $tulos;
  }
  </code></pre>
  
  <p>And here is the page that I want to show in the message:</p>
  
  <pre><code>$levels=$this-&gt;levels;
  $comp=$this-&gt;compdesc;
  echo "Levels explanation for the competence:".$comp['Competence_Description']."&lt;br&gt;";
  
  echo "Level 1 =  ".$levels[0]['lvl1'];
  echo "&lt;br&gt;"."level 2 = ".$levels[0]['lvl2'];
  echo "&lt;br&gt;"."level 3 = ".$levels[0]['lvl3'];
  echo "&lt;br&gt;"."level 4 = ".$levels[0]['lvl4'];
  echo "&lt;br&gt;"."level 5 = ".$levels[0]['lvl5'];
  echo "&lt;br&gt;&lt;br&gt;";
  echo '&lt;input type="button" value="close" window onclick="window.close();"&gt;';
  
  
  
  ?&gt;
  </code></pre>
  
  <p>Any kind of help would be very much appreciated</p>