title: How to take the values using data-list but values is already selected
body: <p>Here i am using data-list i have one URL in that i am passing areaId= 2 &amp; areaName = Chennai,Now i have to take the values and i want to make that value is selected,and again i want to change the areaName so i am changing instead of Chennai , i changed Karur means finally i am clicking submit button means i want to take the areaId &amp; areaName</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code> $('.options').on('change', function() {
       var city_id = $('#options option[value="' + $('#location12').val() + '"]').data('id');
    $('#city_id').val(city_id);
    console.log(city_id);
    
  });
  
  
  function myFunction (){
   
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;form method="POST"&gt;
  &lt;input list="options" type="name" class="form-control options" style="border-radius:0px;height: 36px;" name="location12" id="location12" placeholder="City" rel='&lt;?php echo $_GET['areaId']?&gt;' value='&lt;?php echo $_GET['areaName']?&gt;'&gt;
   &lt;datalist id="options"&gt;
   &lt;option data-id="1" value="Bangalore"&gt;&lt;/option&gt;
   &lt;option data-id="2" value="Chennai"&gt;&lt;/option&gt;
   &lt;option data-id="3" value="Karur"&gt;&lt;/option&gt;
   &lt;/datalist&gt;
  &lt;input type="hidden" name="city_id" id="city_id"&gt;
  &lt;input type="submit" value="submit"&gt;
  &lt;/form&gt;</code></pre>
  </div>
  </div>
  </p>