title: How to display text on click using jquery or ajax?
body: <p>I am new in php. I have a code in which i use <code>HTML``select</code> tag. Now i want to display text below when user click on <code>select</code> tag <code>ptions</code></p>
  
  <p>my select tag code is</p>
  
  <pre><code>&lt;select name="ot"&gt;
    &lt;option value="up"&gt;Update&lt;/option&gt;
    &lt;option value="in"&gt;Initial&lt;/option&gt;
     &lt;/select&gt; 
  </code></pre>
  
  <p>my page result is</p>
  
  <p><a href="https://i.stack.imgur.com/tJ6sJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tJ6sJ.png" alt="enter image description here"></a></p>
  
  <p><strong>Please help me how i can display text on click?</strong></p>
  
  <p>I tried to solve by problem by this example of <a href="http://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_onclick" rel="nofollow noreferrer">W3school</a></p>
  
  <p>MY FULL PAGE CODE IS</p>
  
  <pre><code>&lt;?php
  $servername = "localhost";
  $username = "root";
  $password = "";
  $dbname = "pacra1";
  
  
  $conn = new mysqli($servername, $username, $password, $dbname);
  //$id2 = $_GET['id'];
  $sql= "SELECT r.client_id,c.id,t.id,a.id,o.id,c.name as cname,t.title as ttitle,a.title as atitle,o.title as otitle, l.title as ltitle, s.title as stitle, co.fname, co.mname, co.lname, co.designation, co.city
  FROM og_ratings r 
  LEFT JOIN og_companies c
  ON r.client_id = c.id
  LEFT JOIN og_rating_types t
  ON r.rating_type_id = t.id
  LEFT JOIN og_actions a
  ON r.pacra_action = a.id
  LEFT JOIN og_outlooks o
  ON r.pacra_outlook = o.id
  LEFT JOIN og_lterms l
  ON r.pacra_lterm = l.id
  LEFT JOIN og_sterms s
  ON r.pacra_sterm = s.id
  LEFT JOIN   companies_contact co
  ON c.id = co.companies_id
  WHERE r.client_id= 20
  ORDER BY r.id DESC
  LIMIT 1";
  
  
  $sql1= "SELECT r.client_id,c.id,t.id,a.id,o.id,c.name as cname,t.title as ttitle,a.title as atitle,o.title as otitle, l.title as ltitle, s.title as stitle
  FROM og_ratings r 
  LEFT JOIN og_companies c
  ON r.client_id = c.id
  LEFT JOIN og_rating_types t
  ON r.rating_type_id = t.id
  LEFT JOIN og_actions a
  ON r.pacra_action = a.id
  LEFT JOIN og_outlooks o
  ON r.pacra_outlook = o.id
  LEFT JOIN og_lterms l
  ON r.pacra_lterm = l.id
  LEFT JOIN og_sterms s
  ON r.pacra_sterm = s.id
  WHERE c.id= 20
  ORDER BY r.id DESC
  LIMIT 1,1";
  
  $result = $conn-&gt;query($sql);
  
  $result1 = $conn-&gt;query($sql1);
  //$array = array('1','2','3');
  
  while ($row = $result-&gt;fetch_assoc()){
      while ($row1 = $result1-&gt;fetch_assoc()){
  
  ?&gt;
  
  
  &lt;!DOCTYPE html&gt;
  &lt;html lang="en"&gt;
  &lt;head&gt;
      &lt;title id='Description'&gt;Notification Letter.&lt;/title&gt;
      &lt;link rel="stylesheet" href="jqwidgets/styles/jqx.base.css" type="text/css" /&gt;
  
  
      &lt;style&gt;
  a:link {
      text-decoration: black;
  }
  
  a:visited {
      text-decoration: black;
  }
  
  a:hover {
      text-decoration: none;
  }
  
  
  &lt;/style&gt;
  &lt;/head&gt;
  &lt;body link="#000000"&gt;
  
      &lt;div style=" margin-left:auto; margin-right:auto; width: 60%"&gt;
      &lt;div style="margin-top: 10px; width: 800px; font-family: 'Times New Roman', Times, serif;"&gt;
      &lt;div style=" margin:auto; width:60px; height:auto; align: middle"&gt;
      &lt;img src="image/pacra_logo.png" alt="logo"&gt;
      &lt;/div&gt;
      &lt;div style="margin:auto; width:auto; text-align:center; font-family:'Times New Roman', Times, serif; font-variant: small-caps; font-size:20px; font-weight:bold"&gt;
      The Pakistan Credit Rating Agency Limited 
      &lt;hr&gt;
      &lt;/div&gt;
      &lt;/div&gt;
      &lt;form action="test1.php" method="POST"&gt;
      &lt;div style="margin-top: 10px; width: auto"&gt;
  
   &lt;div style="width: auto; float:" contenteditable="true"&gt; &lt;input type="text" name="nl" id="nl" value="NL FY 15" readonly /&gt; &lt;/div&gt;
  
   &lt;div style=" margin-top:10px; width:280px; float:left; font-family:'Times New Roman', Times, serif; text-align:left; font-size:14px" contenteditable="true" align="center"&gt;
   &lt;input type="text" name="to_name" value="&lt;?php echo $row['fname']?&gt; &lt;?php echo $row['mname']?&gt; &lt;?php echo $row['lname']?&gt;" readonly/&gt; &lt;br&gt; &lt;input type="text" name="to_designation" value="&lt;?php echo $row['designation']?&gt;" readonly/&gt; &lt;br&gt; &lt;input type="text" name="company" value="&lt;?php echo $row['cname'] ?&gt;" readonly/&gt; &lt;br&gt; &lt;input type="text" name="address" value="&lt;?php echo $row['city'] ?&gt;" readonly/&gt;&lt;/div&gt;
  
   &lt;div style=" margin-top:10px; margin-left:300px; width:auto; float:left; font-family:'Times New Roman', Times, serif; text-align:right; font-size:14px" contenteditable="true" align="center" &gt;&lt;input type="text" name="confidential" value="Confidential" readonly/&gt;&lt;br&gt;&lt;input type="date" /&gt;&lt;/div&gt;
  
   &lt;div style="margin-top: 110px; width:auto" align="center"&gt;
   &lt;input type="text" name="company" value="&lt;?php echo $row['cname'] ?&gt;" width="500px" readonly/&gt;
   &lt;/br&gt;
   &lt;table&gt; &lt;tr&gt; &lt;td&gt; &lt;input type="text" name="er" value="Entity Ratings - " readonly/&gt; 
   &lt;select name="ot"&gt;
    &lt;option value="up"&gt;Update&lt;/option&gt;
    &lt;option value="in"&gt;Initial&lt;/option&gt;
     &lt;/select&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
   &lt;/div&gt;
   &lt;/div&gt;
   &lt;div style="margin-top: 10px; width: auto" &gt;
   &lt;div style="margin-top:10px; width:auto"&gt;
   &lt;input type="text" name="dear_sir" value="Dear &lt;?php echo $row['fname']?&gt; &lt;?php echo $row['lname']?&gt;"/&gt;
   &lt;/div&gt;
   &lt;/div&gt;
  
  
   &lt;div&gt;
  &lt;!------------------------- HERE I WANT TO DISPLAY MY TEXT---------------------------&gt; 
  
   &lt;/div&gt;
  
  
    &lt;div style="margin-top: 70px; width: auto" align="center"&gt;
   &lt;div style="width:auto; margin-top:10px"&gt; 
   &lt;table border="1"&gt;
          &lt;tr&gt;
              &lt;td&gt; ID &lt;/td&gt;
              &lt;td&gt; &lt;?php echo $row['client_id'] ?&gt; &lt;/td&gt;
          &lt;/tr&gt;
  
          &lt;tr&gt; 
              &lt;td&gt;Name &lt;/td&gt;
              &lt;td&gt;&lt;?php echo $row['cname'] ?&gt; &lt;/td&gt;
          &lt;/tr&gt;
  
          &lt;tr&gt;
              &lt;td&gt;Rating Type &lt;/td&gt;
              &lt;td&gt;&lt;?php echo $row['ttitle'] ?&gt; &lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Action &lt;/td&gt;
              &lt;td&gt;&lt;?php echo $row['atitle'] ?&gt; &lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Outlook &lt;/td&gt;
              &lt;td&gt;&lt;?php echo $row['otitle'] ?&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td rowspan="2"&gt;Long Term Rating &lt;/td&gt;
              &lt;td&gt;Current (&lt;?php echo $row['ltitle'] ?&gt;) &lt;tr&gt;&lt;td&gt;Previous (&lt;?php echo $row1['ltitle'] ?&gt;)&lt;/td&gt; &lt;/tr&gt;&lt;/td&gt;
          &lt;/tr&gt;
  
          &lt;tr&gt;
              &lt;td rowspan="2"&gt;Short Term Rating &lt;/td&gt;
              &lt;td&gt;Current (&lt;?php echo $row['stitle'] ?&gt;) &lt;tr&gt;&lt;td&gt;Previous (&lt;?php echo $row1['stitle'] ?&gt;)&lt;/td&gt; &lt;/tr&gt;&lt;/td&gt;
          &lt;/tr&gt;
  
  
  &lt;/table&gt;
   &lt;/div&gt;
  
   &lt;div style="width:auto"&gt; 
  
   &lt;/div&gt;
   &lt;/div&gt;
   &lt;div style="margin-top:10px; width:auto"&gt;
   &lt;input type="text" name="y_truly" value="Yours truly" readonly/&gt;
   &lt;/div&gt;
   &lt;div style="margin-top:10px; width:450px"&gt;
   &lt;select name="s_name"&gt;
    &lt;option value="shahzad"&gt;Muhammad Shahzad Saleem&lt;/option&gt;
    &lt;option value="hanif"&gt;Jhangeer Hanif&lt;/option&gt;
    &lt;option value="rana"&gt;Rana Nadeem&lt;/option&gt;
    &lt;/select&gt;
  
     &lt;br&gt;
     &lt;select name="s_designation"&gt;
    &lt;option value="coo"&gt;Chief Operating Officer&lt;/option&gt;
    &lt;option value="uh"&gt;Unit Head&lt;/option&gt;
     &lt;/select&gt;
    &lt;/div&gt;
   &lt;div style="margin-top:10px; width:auto"&gt;
   &lt;input type="checkbox" name="chk" value="p_release" checked&gt; Encl: 1) Press Release&lt;br&gt;
    &lt;!--&lt;input type="checkbox" name="chk1" value="p_release" checked&gt; Encl: 1) Press Release&lt;br&gt; --&gt;
    &lt;input type="checkbox" name="chk2" value="r_report"&gt; 2) Rating Report&lt;br&gt;
  
   &lt;/div&gt;
  
  
      &lt;div style="margin-top:10px"&gt;
      &lt;input type="submit" name="submit" value="Submit"&gt;
      &lt;input type="submit" name="submit" value="Save"&gt;
      &lt;/div&gt;
  
      &lt;/form&gt;
  
  &lt;div style="clear: both;"&gt;&lt;/div&gt;
  
      &lt;div style="margin-top:30px; width:800px; float:left; text-align:center; font-family:'Times New Roman', Times, serif; font-size:18px;"&gt;
      &lt;hr&gt;
   &lt;strong&gt;Awami Complex FB-1, Usman Block, New Garden Town, Lahore-54600, Pakistan&lt;/strong&gt;  
   &lt;/br&gt;PABX: 92(42)35869504 Fax: 92(42)35830425 Email: pacra@pacra.com 
   &lt;/br&gt;&lt;a href="http://www.pacra.com/"&gt;www.pacra.com&lt;/a&gt;
      &lt;/div&gt;
      &lt;/div&gt;
  
      &lt;/div&gt;
  
      &lt;/body&gt;
  &lt;/html&gt;
  
  
  &lt;?php
      }
  }
  ?&gt;
  </code></pre>