title: MVC dropdownlist onchange call jquery
body: <p>I have a <code>SelectList</code> representing a delivery type for an order.</p>
  
  <p>The delivery type reference data has the usual code/description, but also an additional boolean property which indicates if further information needs to be entered for the type selected.</p>
  
  <p>So for Emergency deliveries additional data is required.  The additional data entry fields would be set visible if Emergency was selected, otherwise hidden </p>
  
  <p>My <code>ViewModel</code> contains <code>&lt;List&gt;ReferenceDeliveryTypes</code> which contains the 3 properties.
  I have created a <code>SelectListItems</code> from the ViewModel data</p>
  
  <pre><code>@Html.DropDownListFor(model =&gt; model.DeliveryTypeCode, 
      new SelectList(Model.ReferenceDeliveryTypes as System.Collections.IEnumerable, 
          "DeliveryTypeCode", "DeliveryTypeDescription"), new { id = "ddlDeliveryType" })
  </code></pre>
  
  <p>How can I call a jQuery function on change of the delivery type, pass the selected code and check the <code>Model.ReferenceDeliveryTypes</code> for that code to see if the additional data property is true/false to show/hide the additional fields <code>div</code>?</p>
  
  <p>I have managed to get the jQuery function called to pass the value.</p>
  
  <pre><code>$(function () {
  
  $('#ddlDeliveryType').change(function () {
      var value = $(this).val();
      alert(value);
  });
  </code></pre>
  
  <p>});</p>