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

  • SEARCH
  • Home
  • 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 8894305
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T23:27:47+00:00 2026-06-14T23:27:47+00:00

I am working on a Challenge Engine web application that allows users to create

  • 0

I am working on a “Challenge Engine” web application that allows users to create challenges and compete with each other. I am using MVC 4 C#, razor syntax.

I am trying to make a page where the user can either create a challenge, or edit the details of a challenge he has already created. The way I want this to work is to have a drop-down menu of the challenges a user owns, a submit button, and two text fields below. When a challenge is selected from the drop-down, the two text fields should populate with the challenge name and the challenge description. I am not sure how to accomplish this, although I think it may involve somehow calling additional code that needs to be put into the controller (although maybe not). It may also require JavaScript, jQuery, and/or AJAX, but my understanding of these technologies is still somewhat shaky. Can anyone help, or point me in the right direction? I have Googled this extensively the past couple of days and searched stack overflow, but couldn’t find anyone doing quite what I’m trying to do.
Below is the relevant code I have so far.

The Challenge Model:

public class ChallengeModel
{
    public int ChallengeId { get; set; }
    public String Name { get; set; }
    public String Description { get; set; }
}

The Challenge Controller:

public class ChallengeController
public ActionResult Index()
    //Note: UserService and Challenge Service are part of the service layer;
    //They simply encapsulate the methods in the various DAOs.
    {
        ViewBag.CurrentUserName = WebSecurity.CurrentUserName;
        ViewBag.CurrentUser = UserService.GetUserByName(ViewBag.CurrentUserName);
        ViewBag.OwnedChallenges =
            ChallengeService.GetActiveChallengesByParticipant(CurrentUser);

        return View();
    }

The Challenge View (index.cshtml):

<div class="challengeOwner">
<em>Challenges you own:</em>
<select id="selectOwnedChallenges">

    <option>Create new challenge...</option>
@foreach (ChallengeModel Challenge in ViewBag.OwnedChallenges)
{
    <option id="@Challenge.ChallengeId"
    value="@Challenge.ChallengeId"
    onclick="  [[[INSERT CODE HERE THAT WILL POPULATE TEXT FIELDS
    WITH CHALLENGE NAME AND DESCRIPTION]]]  ">@Challenge.Name</option>
}


</select>
<input id="ChallengeName" type="text" name="Name"
    value="@selectedChallenge.Name"/><br />
<input id="ChallengeDescription" type="text" name="Description"
    value="@selectedChallenge.Description"/>
<input id="updateChallenge" type="button" value="Submit" />
</div>

As you can see, I thought I would use a variable @selectedChallenge to represent the challenge selected in the drop-down. I don’t know how to set it, and I’m thinking this is probably not how it should be done, but I left it there for now so you can see my intention. Any help would be greatly appreciated.
Thanks in advance!

  • 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-14T23:27:48+00:00Added an answer on June 14, 2026 at 11:27 pm

    You can use data attributes to hold the name and description of each option.

    <option value="@Challenge.ChallengeId"
            data-name="@Challenge.Name"
            data-description="@Challenge.Description">
            @Challenge.Name</option>
    

    Then use jQuery to update the input fields when the select changes:

    // this runs when the DOM is finished loading http://api.jquery.com/ready/
    $(document).ready(function() {
    
      // wire up the change handler http://api.jquery.com/change/
      $("#selectOwnedChallenges").change(function() {
    
        // get the selected option's data values http://api.jquery.com/data/
        var data = $("#selectOwnedChallenges option:selected").data();
    
        // set the inputs
        $("#ChallengeName").val(data.name);
        $("#ChallengeDescription").val(data.description);
      });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm now working on a challenge from website http://www.net-force.nl/challenges/ and I stand before an
I'm working on a project that's trying to implement some editing features using a
I'm working on an ASP.NET MVC 3 application. I primarily come from a ASP.NET
I'm working on a project that includes a page of ASP.Net web parts. It
I'm working on an Android application that will come with lots of data. I'd
I have a challenge with my Rails 3.0.9 application, had been working well until
Working on a small game using an HTML5 canvas, and javascript. And it's working
Working with an undisclosed API, I found a function that can set the number
Working on a project using Entity Framework (4.3.1.0). I'm trying to figure out how
I'm working on a fairly specialized search engine implementation in Perl, it searches (by

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.