add or remove a datepicker from a tex field according to seleced dropdown value
<p>I have a form used to search data.  On that form I have a textbox, a dropdown list, and a search button.  In my dropdown, I have options: </p>

<ul>
<li>check in date</li>
<li>last name </li>
<li>reservation id </li>
</ul>

<p>I want to add a datepicker to the textbox, but only when "check in date" has been selected.</p>

<p>Once the date picker is added to the text box - I can't remove it. How can I remove the datepicker when the other options have been selected?</p>

<p>This is my jquery </p>

<pre><code>$('#list').change(function() {
  var selected = $(this).val();

  if(selected == 2) {
    $('#text').datepicker({ dateFormat: 'yy-mm-dd' });
  } else {
    $('#text').prev().val(''); //here , need to remove the date picker 
  } 
});
</code></pre>
