title: Create barcode reader using AJAX in PHP
body: <p>I'm trying to build an application using php. in "stock_out.php", i wanna create a form that include two barcodes. I have 8 fields. (1)Effectivedate,(2)Partnumber,(3)Description1,(4)Description2,(5)NPK,(6)Nama,(7)QtyOut,(8)Reason. I wanna using barcode-reader in "Partnumber" and "NPK".<br/>
  I have some problems:<br/>
  1. When i press enter, it's respon for button submit.<br/>
  2. Actually, when i press enter in Partnumber, i want show details data in "description1" and "description2". As well as in NPK, i want show details data in "nama"<br/>
  3. In the end of form, i still want to submit this form into database.<br/>
  I'm newbie in AJAX, so i still don't know how to implementation AJAX in PHP. This is my code, I am grateful for the help</p>
  
  <pre><code>&lt;html&gt;&lt;body&gt;
  &lt;div id="outerContainer"&gt;
      &lt;?php include("headerFile.html"); ?&gt;
      &lt;?php include("navigationFile.html"); ?&gt;
      &lt;div id="bodyContainer"&gt;
          &lt;div id="pageBodyTitle"&gt; Stock Out &lt;/div&gt; &lt;br&gt;
          &lt;form id="formSearch" name="formSearch" method="post" action="proses_out.php" onSubmit="return cek_data();"&gt;
          &lt;table id="messageTable"&gt;
              &lt;tr&gt;
                  &lt;td class="heading"&gt; Effective Date &lt;/td&gt;
                  &lt;td&gt;
                      &lt;input class="inputField" name="tgl" type="text" readonly  value="&lt;?php echo $_POST['tgl']?&gt;" tabindex="1"/&gt;
                      &lt;script language='JavaScript'&gt;new tcal ({'formname': 'formSearch','controlname': 'tgl'});&lt;/script&gt;
                  &lt;/td&gt; 
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td class="heading"&gt; Part Number &lt;/td&gt;
                  &lt;td&gt;&lt;input type='text' name='txtItem' id='txtItem' size="20" class="inputField" value='&lt;?php echo $item;?&gt;' tabindex="2" /&gt;
                  &lt;img src='search.ico' onClick='open_win_item()'&gt; &lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td class="heading"&gt;Description1&lt;/td&gt;
                  &lt;td&gt;&lt;input type='text' name='txtDesc1' id='txtDesc1' size="50" value='&lt;?php echo $desc1;?&gt;'  readonly /&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td class="heading"&gt;Description2&lt;/td&gt;
                  &lt;td&gt;&lt;input type='text' name='txtDesc2' id='txtDesc2' size="50" value='&lt;?php echo $desc2;?&gt;'  readonly /&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td class="heading"&gt; NPK &lt;/td&gt;
                  &lt;td&gt;&lt;input type='text' name='txtNpk' id='txtNpk' size="20" maxlength="5" class="inputField" value='&lt;?php echo $tr_no;?&gt;' tabindex="3" /&gt;
                      &lt;img src='search.ico' onClick='open_win_npk()'&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td class="heading"&gt;Nama&lt;/td&gt;
                  &lt;td&gt;&lt;input type='text' name='txtName' id='txtName' size="30" value='&lt;?php echo $nama;?&gt;' readonly /&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td class="heading"&gt; Qty Out &lt;/td&gt;
                  &lt;td&gt;&lt;input type='text' name='txtQty' id='txtQty' size="5" class="inputField" tabindex="4"/&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td class="heading"&gt; Reason &lt;/td&gt;                   
                  &lt;td&gt;&lt;select class="inputField" name="choose" id="choose" value="" tabindex="5"&gt;
                  &lt;?php
                  include "/class/connect_SQL.class.php";
                  $sql = "select reason_code from Inv_reason_master";
                  $query = mssql_query($sql);
                      while ($row = mssql_fetch_array($query)) 
                      {
                          $coba = $row['reason_code'];
                      ?&gt;
                          &lt;option value="&lt;?php echo $coba; ?&gt;"&gt;&lt;?php echo $coba;?&gt;&lt;/option&gt;
                      &lt;?php
                      }
                      ?&gt;
                  &lt;/select&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td colspan="2"&gt;
                      &lt;input type="submit" name="Submit" value="Save" class="formButton2" tabindex="6"/&gt;
                      &lt;input type="reset" name="reset" value="Cancel" class="formButton2" tabindex="7"/&gt;
                  &lt;/td&gt;
              &lt;/tr&gt;
          &lt;/table&gt;
  
          &lt;/form&gt;
      &lt;/div&gt;
      &lt;?php
          if(isset($_GET["message"]) and  $_GET["message"]='save')
          {
              echo "&lt;script language=\"javascript\"&gt; alert('Data Tersimpan!') &lt;/script&gt;";
          }
      ?&gt;
      &lt;?php include("footerFile.html"); ?&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>
  </p>