I have the following dropdown lists in my code that are populated from a backend repository.
<h3>Upload Course Section Content</h3>
  <div class="row">
    <div class="nine columns">
      <label for="name">Select Course:</label>
      <select id="coursedd" name="courseid" style="height:40px; font-size:18px;">
      <option value="0" id ="defaultcid" class ="choosefilter" >----Please Select Course----</option>
      @foreach (var course in Model.GetCourseList())
      {
        <option value="@course.CourseID" id ="courseid" class ="choosefilter" >@course.Name </option>
      }
      </select>
    </div>
  </div>
  <div class="row" style="margin-top:30px;">
    <div class="nine columns">
      <label for="name" id="namelabel">Select Course Section:</label>
      <select id="coursesectiondd" name="coursesectionid" style="height:40px; font-size:18px;">
      <option value="0" id ="defaultcs" class ="choosefilter" >----Please Select Course Section----</option>
      @foreach (var courseSection in Model.GetCourseSectionsByCourseID(Model.CourseID))
      {
        <option value="@courseSection.CourseSectionID" id ="coursesectionid" class ="choosefilter" >@courseSection.Title </option>
      }
      </select>
    </div>
  </div>
The second of the dropdowns is initially hidden and upon selection of the first dropdown I wish to populate the secondary dropdown. I have tried using the following jquery and javascript but have been unable to do so. Can anyone please help me to get this working:
 function GetCourseID() {
    var id = document.getElementById("coursedd").value;
    var postData = {
        'CourseID': id
    };
    $.post('/Admin/GetCourseID/', postData, function (data) {
        document.getElementById("coursedd").selectedIndex = id;
        document.getElementByID("coursesectiondd").show();
    });
};
$(function () {
    $("#coursedd").change(function () {
        $('#namelabel').show();
        $('#title').show();
        $('#CourseSectionSubmit').show();
        var chosen = document.getElementById("coursedd").value;
        if (chosen == "0") {
            $('#namelabel').hide();
            $('#coursesectiondd').hide();
            $('#file').hide();
            $('#filelabel').hide();
        }
        else {
            $('#coursesectiondd').show()
            GetCourseID()
            $('#coursesectiondd').a
        }
    });
});
In my controller I have the following, I thought that this would update the viewmodel with the appropriate values to then populate the secondary dropdown but nothing is being shown.
[HttpPost]
    public ActionResult GetCourseID(int courseID)
    {
        avm.CourseID = courseID;
        return View(avm);
    }
 
     
    