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 7978529
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T09:30:50+00:00 2026-06-04T09:30:50+00:00

I have a simple password reset form that has a username field, and below

  • 0

I have a simple password reset form that has a username field, and below it, a drop down list for security questions.

What I am trying to get working is when the user types in a valid username, when they unfocus from the textbox, I want to have it so that the drop down list will populate with the users security questions as found in my database.

Here is my HTML

    <div class="editor-field">
        @Html.TextBoxFor(model => model.userName, new { @Id = "forgotPassUserName" })
        @Html.ValidationMessageFor(model => model.userName)
    </div>

    <div class="editor-field">
    @{
        List<SelectListItem> securityquestionvalues = new List<SelectListItem>();
    }
        @Html.DropDownListFor(model => model.securityQuestion, securityquestionvalues, new { @Id = "forgotPassSecurityQuestions" })

Here is my jQuery/JS

<script type="text/javascript">
$(function () {
    $("#forgotPassUserName").change(function () {
        var selectedValue = $(this).val();
        $.getJson("LoginRegisterController/ForgotPasswordDropDownList", { user: selectedValue }, function (result) {
            var selectList = $("#forgotPassSecurityQuestions");
            selectList.add(result, null);

        });
    });
});

Here is the method in the controller that gets called by the getJSON above:

        public ActionResult ForgotPasswordDropDownList(string userName)
    {
        var db = IoC.ResolveObjectContextelearningCommon();

        var rep = db.GetRepository<EmployeeReg>();

        List<EmployeeReg> user = rep.Find(o => o.Login == userName).ToList();

        List<SelectListItem> questionList = new List<SelectListItem>();

        if (user[0].secureQuestion1 != null)
        {
            questionList.Add(new SelectListItem { Text = user[0].secureQuestion1, Value = user[0].secureQuestion1 });
        }

        if (user[0].secureQuestion2 != null)
        {
            questionList.Add(new SelectListItem { Text = user[0].secureQuestion2, Value = user[0].secureQuestion2 });
        }

        return Json(questionList, JsonRequestBehavior.AllowGet);
    }

Unfortunately. This is not working for me. I unfortunately get errors when I try to breakpoint at the getJSON method. The issue seems to be in there.

EDIT

I changed my getJSON method to .ajax like so

<script type="text/javascript">
$(function () {
    $("#forgotPassUserName").change(function () {
        var selectedValue = $(this).val();
        var url = '<%= Url.Action("ForgotPasswordDropDownList", "LoginRegisterController") %>';
        $.ajax({
            type: "GET",
            url: url,
            data: { userName: selectedValue },
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (result) {
                alert("testing");
            }
        });
    });
});

Still getting no alert popup….

  • 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-04T09:30:51+00:00Added an answer on June 4, 2026 at 9:30 am

    The following line isn’t right:

    selectList.add(result, null);
    

    You’ll need a for loop instead to add them to the Select List, something like:

    selectList.html(""); //empty the options first
    
    for (var i = 0; i < result.length; i++)
    {
        selectList.append("<option value='" + result[i].Value  + "'>" 
            + result[i].Text  + "</option>");
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code that asks for a username and password. Just a simple
I have simple login form in my website. In given requirements stands, that password
I have a simple contact form on a website that has 2 text fields,
I am using database with a list of username/passwords, and a simple web form
I'm trying to check that the fields in the form below have been filled
I have a simple db.Model , that has one of the fields db.ListProperty(users.User) For
I have simple reset password structure for users to update their existing passwords if
i have a form with 2 fields username: password: and a submit button. the
I have to create a simple form that uses JSP for the view with
I have a simple application which takes a text and password, generates a text

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.