title: MVC Javascript Set Text Input Value Based on Model
body: <p>I have an Html.DropDownListFor, a textbox, and a model that contains a list "sourceWatchListParameters".  </p>
  
  <p>My end goal is, when an item is selected in the dropdownlist, populate the textbox with a property "DefaultParameter" for that particular sourceWatchList.</p>
  
  <pre><code>$(function() {
      $('select#WatchListDropDown').change(function () {
          var e = document.getElementById("#WatchListDropDown").selectedIndex.value;
  
          @foreach (var watchlist in Model.sourceWatchListParameters)
          {
              @:if (watchlist.WatchListId == e)
              {
                  @: var def = document.getElementById("expDefault");
                  @: def.value = watchlist.DefaultParameter;
              }
          }
  
      })
  });
  </code></pre>
  
  <p>The function is called correctly, but I can't figure out the logic/syntax to locate the right sourceWatchListParameter and display its DefaultParameter.  As it is now, I see no change in the textbox on selection.  I'm sure there's a simpler way to rewrite this.</p>
  
  <p>Thanks for any guidance</p>