title: Set Value Sql Query Result in Input Field From Another Input Field Value (Dynamic Input Field)
body: <p>I have a problem to display query result in Input field based on value entered by user in another input field. This is dynamic input field (user can add or delete row using javascript). This is my code :</p>
  
  <pre><code>&lt;script language="javascript" type="text/javascript"&gt;
      /*
      Javascript Multi Field Dynamic Generator
      */
      var ct = 1;
  
      // Function Tambah Form
      function new_link()
      {
          ct++;
          var div1 = document.createElement('div');
          div1.id = ct;
  
      // Link to Delete Form
      var delLink = '&lt;div style="text-align:left"&gt;&lt;a id="del" href="javascript:delIt('+ ct +')"&gt;Delete&lt;/a&gt;&lt;/div&gt;';
      div1.innerHTML = document.getElementById('newlinktpl').innerHTML + delLink;
      document.getElementById('newlink').appendChild(div1);
  }
  // Function Delete Form
  function delIt(eleId)
  {
      d = document;
  
      var ele = d.getElementById(eleId);
  
      var parentEle = d.getElementById('newlink');
  
      parentEle.removeChild(ele);
  
  }
  
  &lt;/script&gt;
  
  &lt;a id="new" href="javascript:new_link()"&gt;ADD NEW PAYMENT &lt;/a&gt;&amp;nbsp;&amp;nbsp;
      &lt;div id="newlink"&gt;
      &lt;table id="fit" width="90%"&gt;
      &lt;tr bgcolor="#E0ECFF"&gt;
      &lt;th&gt;Type&lt;/th&gt;
      &lt;th&gt;IDNO&lt;/th&gt;
      &lt;th&gt;Bank&lt;/th&gt;
      &lt;th&gt;Ket&lt;/th&gt;
      &lt;th&gt;text&lt;/th&gt;
      &lt;th&gt;text&lt;/th&gt;
      &lt;th&gt;option&lt;/th&gt;
      &lt;th align="right"&gt;Amount&lt;/th&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;
          &lt;select name="type[]"&gt;
              &lt;?php
              $sql_paytype = mssql_query("...");
              while($rp = mssql_fetch_array($sql_paytype)){
              ?&gt;
                  &lt;option value="&lt;?php echo "$rp[Kd_Pay]#$rp[RepCd]";?&gt;"&gt;&lt;?php echo $rp[Nm_Pay]?&gt;&lt;/option&gt;
              &lt;?php
              }
              ?&gt;
          &lt;/select&gt;
          &lt;/td&gt;
          &lt;td&gt;
          // USER ENTER PARAMETER VALUE IDNO TO SELECT AMOUNT FROM TABLE WHERE IDNO = $IDNO
          &lt;input style="width:80px;" type="text" name="idno[]" /&gt;
          &lt;/td&gt;
           &lt;td&gt;
          &lt;select name="bank[]"&gt;
              &lt;option value=""&gt;&lt;/option&gt;
              &lt;?php
              $sql_bank = mssql_query("SELECT ...");
              while($rb = mssql_fetch_array($sql_bank)){
              ?&gt;
                  &lt;option value="&lt;?php echo $rb[Kd_Bank]?&gt;"&gt;&lt;?php echo "$rb[Kd_Bank] - $rb[Nm_Bank]";?&gt;&lt;/option&gt;
              &lt;?php
              }
              ?&gt;
          &lt;/select&gt;
          &lt;/td&gt;
          &lt;td&gt;
          &lt;input style="width:90px;" type="text" name="ket[]" /&gt;
          &lt;/td&gt;
          &lt;td&gt;&lt;input style="width:90px;" type="text" name="text[]" /&gt;&lt;/td&gt;
          &lt;td&gt;&lt;input style="width:100px;" type="text" name="text[]" /&gt;&lt;/td&gt;
          &lt;td&gt;
          &lt;select name="option[]"&gt;
              &lt;?php
              $sql_curr = mssql_query("SELECT ...");
              while($rc = mssql_fetch_array($sql_curr)){
              ?&gt;
                  &lt;option value="&lt;?php echo "$rc[KD_CURR]#$rc[KODE]";?&gt;"&gt;&lt;?php echo "$rc[KODE]";?&gt;&lt;/option&gt;
              &lt;?php
              }
              ?&gt;
          &lt;/select&gt;
          &lt;/td&gt;
          &lt;td&gt;
          // AND THEN QUERY RESULT AMOUNT WILL BE DISPLAYED IN THIS INPUT FIELD
          &lt;input style="text-align:right" type="text" name="amount[]" value="&lt;?php echo $msg?&gt;" onKeyUp="formatNumber(this)" /&gt;
          &lt;/td&gt;
      &lt;/tr&gt;
      &lt;/table&gt;
      &lt;/div&gt;
      &lt;br/&gt;
          &lt;input type="submit" name="submit" value="Save" /&gt;&amp;nbsp;&lt;input type="reset" name="reset" value="Reset" /&gt;
   &lt;/form&gt;
   &lt;/fieldset&gt;
  &lt;/div&gt;
  &lt;/fieldset&gt;
  
  &lt;!-- Template For Dynamic Multiple Field --&gt;
  &lt;div id="newlinktpl" style="display:none" &gt;
  &lt;div&gt;
  &lt;table id="fit" width="90%"&gt;
    &lt;tr&gt;
          &lt;td&gt;
          &lt;select name="type[]"&gt;
              &lt;?php
              $sql_paytype = mssql_query("...");
              while($rp = mssql_fetch_array($sql_paytype)){
              ?&gt;
                  &lt;option value="&lt;?php echo "$rp[Kd_Pay]#$rp[RepCd]";?&gt;"&gt;&lt;?php echo $rp[Nm_Pay]?&gt;&lt;/option&gt;
              &lt;?php
              }
              ?&gt;
          &lt;/select&gt;
          &lt;/td&gt;
          &lt;td&gt;
          &lt;input style="width:80px;" type="text" name="idno[]" /&gt;
          &lt;/td&gt;
           &lt;td&gt;
          &lt;select name="bank[]"&gt;
              &lt;option value=""&gt;&lt;/option&gt;
              &lt;?php
              $sql_bank = mssql_query("...");
              while($rb = mssql_fetch_array($sql_bank)){
              ?&gt;
                  &lt;option value="&lt;?php echo $rb[Kd_Bank]?&gt;"&gt;&lt;?php echo "$rb[Kd_Bank] - $rb[Nm_Bank]";?&gt;&lt;/option&gt;
              &lt;?php
              }
              ?&gt;
          &lt;/select&gt;
          &lt;/td&gt;
          &lt;td&gt;
          &lt;input style="width:90px;" type="text" name="ket[]" /&gt;
          &lt;/td&gt;
          &lt;td&gt;&lt;input style="width:90px;" type="text" name="text[]" /&gt;&lt;/td&gt;
          &lt;td&gt;&lt;input style="width:100px;" type="text" name="text[]" /&gt;&lt;/td&gt;
          &lt;td&gt;
          &lt;select name="option[]"&gt;
              &lt;?php
              $sql_curr = mssql_query("...");
              while($rc = mssql_fetch_array($sql_curr)){
              ?&gt;
                  &lt;option value="&lt;?php echo "$rc[KD_CURR]#$rc[KODE]";?&gt;"&gt;&lt;?php echo "$rc[KODE]";?&gt;&lt;/option&gt;
              &lt;?php
              }
              ?&gt;
          &lt;/select&gt;
          &lt;/td&gt;
          &lt;td&gt;
          &lt;input style="text-align:right" type="text" name="amount[]" value="" onKeyUp="formatNumber(this)" /&gt;
          &lt;/td&gt;
      &lt;/tr&gt;
  &lt;/table&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>So, basically <strong>I want input field (name amount[]) will display query result based on input field (idno[]) value that entered by user</strong>..
  Please help me to achieve this..</p>
  
  <p>many thanks</p>