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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T23:21:41+00:00 2026-06-07T23:21:41+00:00

I need some help here. I am using razor view in MVC3. I have

  • 0

I need some help here. I am using razor view in MVC3. I have a search bar with autocomplete feature that is working fine. Now as per the req. I need to create a radio button beside search text box and based on the radio button values selected I need to get the autocomplete text from different tables. It’s because, my index page view has 3 different webgrid listing. so, search should act based on what the user intend to search by specifying the option in the parameter as radio button.

I have my regular jQuery code here:

$(document).ready(function () {
    $(":input[data-autocomplete]").each(function () {
        $(this).autocomplete({ source: $(this).attr("data-autocomplete") });
    })
})*  

I modified the above to pass second parameter :-

$(document).ready(function () {

    var radioval = $("#form0").find("input[type=radio]").attr("value");
    $(":input[data-autocomplete]").each(function (request) {
        var srctxt = $(this).attr("value");
        $(this).autocomplete({
            source: "/Facility/FindNames/?term = " + $(this).attr("value") + "&stype = " + radioval
        });
    })
})

My intention is to pass the second parameter search type which is a radio button group and then in the controller below based on the value passed change the query to select from different tables.

–Controller Method

 public JsonResult FindNames(string term, string stype)
    {

        string radioValue = null;

        var result = _service.GetAllFacility()
                    .Where(r => r.FacilityName.Contains(term))
                    .Take(10)
                    .Select(r => new { label = r.FacilityName });

        return Json(result, JsonRequestBehavior.AllowGet);
    }

however the value of stype is always coming as null. Using firebug I can see it does have value. Can someone tell me what is wrong with my code? What is the best way to implement this kind of search feature?

  • 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-07T23:21:44+00:00Added an answer on June 7, 2026 at 11:21 pm

    You could handle the source function as follows to pass multiple parameters

    var radioval = $("#form0").find("input[type=radio]").attr("value");
    $(":input[data-autocomplete]").each(function() {
    
         $this = $(this);
         var srctxt = $this.val();
         $this.autocomplete({
              source: function (request, response) {
                 $.getJSON('/Facility/FindNames/',
                 {
                    stype: radioval,
                    term: srctxt
                 }, response);
              }
         });
    })
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need some help with a rails development that I'm working on, using rails
I need some help extracting the following bits of information using regular expressions. Here
I need some advanced CSS help here. I have a login button and a
Need some help here. I have deployed spree (0.70.3) on slicehost (ubuntu, ruby1.8.7, Rails
I'm confused about how DQL works, and really need some help here. I have
I need some help to find a View inside a hierarchy. Here is how
I have just started using CodeContracts with C#, and I might need some help.
Need some help, I have a regular expression that appears to work just fine
Having some issue with Threadpooling here that I need some help with please. I
need some help here My problem is, my app starts with a single view,

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.