title: I am new to node js how to get dependent dynamic dropdown from database
body: <p>my node code:</p>
  
  <pre><code>app.get('/block_name', function (req,res){
  
  var sql='SELECT  `block_name`,`block_id` FROM `tbl_block`  ';
  connection.query(sql,function(err, result) {
      if (err) throw err;
      res.json(result);
  });
  </code></pre>
  
  <p>});</p>
  
  <p><code>app.get('/site_name', function (req,res){</code></p>
  
  <pre><code>var sql='SELECT  `site_name`,`site_id` FROM `tbl_site` ';
  connection.query(sql,function(err, result) {
      if (err) throw err;
      res.json(result);
  });
  </code></pre>
  
  <p>});</p>
  
  <p>HTML</p>
  
  <p>Site</p>
  
  <pre><code>      &lt;select name="site" id="dropdown" &gt;
          &lt;option value=""&gt;- select -&lt;/option&gt;
        &lt;/select&gt;
       &lt;label class="field" &gt;Block&lt;/label&gt;
        &lt;select name="block" id="dropdown1" &gt;
          &lt;option value=""&gt;- select -&lt;/option&gt;
        &lt;/select&gt;
  </code></pre>
  
  <p>SCRIPT</p>
  
  <pre><code>&lt;script&gt;
  
      $(document).ready(function(){
      $.ajax({
          url : "/site_name",
          type : "GET",
          success : function(data){
  
              var len = data.length;
  
              console.log(data);
              $("#dropdown").empty();
              for(var i =0; i&lt;len;i++){
              var value1 = data[i]['site_name'];
              var value2 = data[i]['site_id'];
                  $("#dropdown").append("&lt;option value='"+value2+"' &gt;"+value1+"&lt;/option&gt;");
  
              }
  
          }
      });
  }); 
  
      $(document).ready(function(){
      $.ajax({
          url : "/block_name",
          type : "GET",
          success : function(data){
  
              var len = data.length;
  
              console.log(data);
              $("#dropdown1").empty();
              for(var i =0; i&lt;len;i++){
              var value1 = data[i]['block_name'];
              var value2 = data[i]['block_id'];
                  $("#dropdown1").append("&lt;option value='"+value2+"' &gt;"+value1+"&lt;/option&gt;");
  
              }
  
          }
      });
  }); 
  
  
   &lt;/script&gt;
  </code></pre>
  
  <p>my second dropdown lists all the data but i need particular thing to be listed according to the first dropdown.
  Thanks in advance..
  Sorry for my bad English</p>