Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8209411
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T09:42:42+00:00 2026-06-07T09:42:42+00:00

I have two models: public class ProfessorModels { public string FullName { get; set;

  • 0

I have two models:

public class ProfessorModels
{
    public string FullName { get; set; }
    public int ID { get; set; }
}

and

public class ClassModels
{
    public int ID { get; set; }
    public string Professor { get; set; }
    public decimal Name { get; set; }
}

in my View there is a form to add the class:

@model MvcApp.Models.ClassModels

@{
    ViewBag.Title = "Create";
}

<h2>Create</h2>

<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>

@using (Html.BeginForm()) {
    @Html.ValidationSummary(true)
    <fieldset>
        <legend>ClassModels</legend>

        <div class="editor-label">
            @Html.LabelFor(model => model.Name)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Name)
            @Html.ValidationMessageFor(model => model.Name)
        </div>

        <p>
            <input type="submit" value="Create" />
        </p>
    </fieldset>
}

<div>
    @Html.ActionLink("Back to List", "Index")
</div>

I would like to add a drop-down menu to the Class View, which lists all the available professors. Professors are in db, and I can easily make a call to db from controller and load all professors in to some list/array.
I need help with how to populate the drop-down with professors using jQuery.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T09:42:44+00:00Added an answer on June 7, 2026 at 9:42 am

    In your controller:

        [HttpGet]
        public virtual JsonResult LoadInfo()
        {
            var query = _repository.GetInformation(); //Here you return the data. 
            return Json(query, JsonRequestBehavior.AllowGet);
        }
    

    Then in your view:

    <select id="info"></select>
    

    Then you load the drop down using jQuery

    function LoadInfo() {
    
        $.getJSON("@Url.Action(MVC.ControllerName.MethodName())", null,
            function (data) {
    
                $("#info").empty();
    
                $.each(data, function () {
                    $("#info").append($("<option />").val(this.Id).text(this.Name));
                });
    
            });
    }
    

    This assumes that Id and Name are properties of your object. You could use ID and FullName depending on which drop down you’re loading. I also use T4MVC to get the different method names.

    Hope this helps,

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have these two models public class Group { [Key] public int GroupID {
I have the following two models [DataContract] public class Event { [Key] public int
I have two classes: public class DocumentViewModel { public virtual string DocumentNumber { get;
I have two models: class Contact(models.Model): name = models.CharField(max_length=255) class Campaign(models.Model): contact = models.ForeignKey(Contact,
I have two models : class A extends Model { public bool active =
I have my view models : public class POReceiptViewModel { public virtual int PONumber
I have two classes defined as such: public class Questionnaire { public int QuestionnaireID
Say I have these two models: public class City extends Model { @ManyToOne private
I have a simple Fluent NHibernate model with two related classes: public class Applicant
I relised I have lots of models view models with those two properties public

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.