title: Sending a different column instead of this.value in php to javascript function (Query)
body: <p>I've made a select list and filled it with info from a DB. Now i'm trying to make it so whenever you select a different item in the list it calls a javascript function that checks if the selected item/entity (or whatever it's supposed to be called) has a comment or not, and reacts accordingly.</p>
  
  <p>So far I have this, which does work, and only shows the paragraph if the ID of the selected item sent is over 5. However, I don't know how to send the  comment that is in the query as the parameter, so that it can then check the length and react.</p>
  
  <p>This is what I have so far:</p>
  
  <pre><code>// Create connection
  $conn = mysql_connect("localhost", "root", "admin") 
  or die("Could not connect: " . mysql_error());
  
  // Selecting the DB
  mysql_select_db("tickets") or die("Could not connect: " . mysql_error());
  
  $query = mysql_query("SELECT * FROM tickets order by ID");
  $numrows = mysql_num_rows($query);
  
  //I want to change this.value to be the selected item's comment
  echo '&lt;select name="Tick" size='.$numrows.' onChange="checkSelectedValue(this.value)"&gt;';
  
  while ($row = mysql_fetch_array($query)) {
      echo '&lt;option value="'.$row['ID'].'"&gt;Comment: '.$row['comments'].' &lt;/option&gt;';
  }
  
  echo '&lt;/select&gt;';
  
  echo '&lt;p id="commentNotifier" style='display:none;'&gt; Selected item has a comment. &lt;/p&gt;';
  </code></pre>
  
  <p>How would I modify this so the parameter of <em>onChange="checkSelectedValue(this.value)"</em> would be the selected item's comment instead of this.value which is, in my case, the ID.</p>
  
  <p>Note that I don't want to change the <em>value</em> of each option to be comments instead of ID.</p>
  
  <p>This is the javascript functon that works with the ID sent, and if it is over 5 it shows the paragraph that's otherwise hidden:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      function checkSelectedValue(val){
          var element=document.getElementById('commentNotifier');
          if(val &gt; 5) //I would change this to val.length &gt; 0 to check if comments exists or not
              element.style.display='block';
          else
              element.style.display='none';
      }
  &lt;/script&gt;
  </code></pre>
  
  <p>Pretty straightforward function. Cheers in advance!</p>