title: Store value from date picker on to a variable
body: <p>I have a jquery date picker.</p>
  <p>Code</p>
  <pre class="lang-html prettyprint-override"><code>&lt;!doctype html&gt;
  &lt;html lang=&quot;en&quot;&gt;
  &lt;head&gt;
    &lt;meta charset=&quot;utf-8&quot;&gt;
    &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1&quot;&gt;
    &lt;title&gt;jQuery UI Datepicker - Default functionality&lt;/title&gt;
    &lt;link rel=&quot;stylesheet&quot; href=&quot;//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css&quot;&gt;
    &lt;link rel=&quot;stylesheet&quot; href=&quot;/resources/demos/style.css&quot;&gt;
    &lt;script src=&quot;https://code.jquery.com/jquery-1.12.4.js&quot;&gt;&lt;/script&gt;
    &lt;script src=&quot;https://code.jquery.com/ui/1.12.1/jquery-ui.js&quot;&gt;&lt;/script&gt;
    &lt;script&gt;
    $( function() {
      $( &quot;#datepicker&quot; ).datepicker();
    } );
    &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
   
  &lt;p&gt;Date: &lt;input type=&quot;text&quot; id=&quot;datepicker&quot;&gt;&lt;/p&gt;
   
   
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  <p>I have looked at other solutions but it did not solve my problem.(<a href="https://stackoverflow.com/questions/10266456/get-selected-value-in-datepicker-and-format-it">get selected value in datePicker and format it</a>) I basically want to store the date selected from date picker to a variable so I can pass the variable on to a sql query. In my database the date is in the format of dd/mm/yyyy. Any help is truly appreciated. Thanks</p>
  <p>what i tried</p>
  <pre><code>&lt;script&gt;
   $( &quot;#datepicker&quot; ).datepicker({ dateFormat: 'dd, mm, yy' });
    var datevariable = $(&quot;#datepicker&quot;).val();
    console.log(datevariable);  // i see no value
      &lt;/script&gt;
  </code></pre>