Can we get multiple values ​​from select tag via Ajax script in asp.net MVC controller?

can we get multiple values ​​from select tag via Ajax script in controller in asp.net MVC?

I tried one value that I made with the .val function.

But not for multiple values

Any suggestion Please help

+2


a source to share


1 answer


Yes, you can create a multi-selection like this:

<select multiple="multiple" name="cars">
  <option value="volvo">Volvo</option>
  <option value="saab">Saab</option>
  <option value="mercedes">Mercedes</option>
  <option value="audi">Audi</option>
</select>

      

And your controller action should look something like this:



    [AcceptVerbs(HttpVerbs.Post)]
    public ActionResult Index(string[] cars)
    {
        // ....
        return View();
    }

      

The ajax post codecan will be the same as in your previous case.

0


a source







All Articles