title: How do I get the value of the selected customer to echo <input> element?
body: <p>Database info:</p>
  
  <pre><code>CREATE TABLE
  IF NOT EXISTS tz_customer (
      id INT (10) NOT NULL,
      customervarchar (255) NOT NULL,
      NAME VARCHAR (255) NOT NULL,
      vs_1 VARCHAR (255) NOT NULL,
      stamp VARCHAR (255) NOT NULL
  )
  </code></pre>
  
  <p>And PHP Code</p>
  
  <p>THIS IS index.php FILE</p>
  
  <p><code>&lt;select name="nimetus" id="nimetus" onchange="chg(this.value)"&gt;</code><br>
  <code>&lt;?php $q3 = mysql_query("SELECT * FROM tz_kliendid"); while ($f3 = mysql_fetch_array($q3)) { ?&gt;</code> <br>
  <code>&lt;option value="&lt;?php echo $f3['id']; ?&gt;"&gt;&lt;?php echo $f3['klient']; ?&gt;&lt;/option&gt;&lt;?php } ?&gt;&lt;/select&gt;</code></p>
  
  <p><code>&lt;input type="text" id="target" value=""&gt;</code></p>
  
  <p><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"&gt;&lt;/script&gt;</code></p>
  
  <p><code>&lt;script type="text/javascript"&gt;function chg(str){
    $.ajax({
              url: "showdata.php",
              type: "POST",
              data: {
                  "val": str
              },
              success: function (response) {
                  $("#target").val(response);
              },
              error: function (xhr) {
                  alert("Some error found!!");
              }
          });
  }&lt;/script&gt;</code></p>
  
  <p>AND showdata.php FILE</p>
  
  <p><code>&lt;?php if(isset($_GET['val'])){$nimetus=$_POST['nimetus'];
          $q1=mysql_query("SELECT vs_1 FROM tz_kliendid WHERE id='".$nimetus."' ORDER BY id DESC LIMIT 1"); $f1=mysql_fetch_array($q1); echo $f1['vs_1']; } ?&gt;</code></p>
  
  <p><br><br><br></p>
  
  <p>Each customer has a "tz customer" table "vs_1" column marked 0 or 1.
  When I choose a customer, how can I reach the selected customer "vs_1" value from the table?</p>
  
  <p>And</p>
  
  <p>How do I get the value of the selected customer to echo <code>&lt;input&gt;</code> element?</p>