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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T07:23:09+00:00 2026-06-11T07:23:09+00:00

I am trying to select items in the following select multiple by there value.

  • 0

I am trying to select items in the following select multiple by there value. The code is below:

<select id="genre" name="genre" multiple="multiple" size="9">
    <option value="1">Action</option>
    <option value="2">Adult</option>
    <option value="3">Adventure</option>
    <option value="4">Comedy</option>
    <option value="5">Drama</option>
</select>

I can select one or two options but the thing is that the number of selected options comes from user which i’m change it to something like this: 1,2,4 (by value).

  • 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-11T07:23:10+00:00Added an answer on June 11, 2026 at 7:23 am

    You can select multiple options by passing an array of values to the .val() function:

    $("#genre").val([1,2,4]);
    

    If instead of an array, you have a comma delimited string, just transform it to an array using split(), before passing it to .val():

    $("#genre").val("1,2,4".split(","));
    

    From the docs:

    .val( value )

    value – A string of text or an array of strings corresponding to the
    value of each matched element to set as selected/checked.

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

Sidebar

Related Questions

I am trying to grab all selected items in the following select multiple and
I am trying to execute the code below to list the select item in
Consider the following code. var items = from i in context.Items select i; var
I am trying to select items between two dates. Time.zone.now seems to respect the
I'm trying to convert this SQL query to LINQ: SELECT Items.p_Name Product, DiamondCategory.dc_Name Category,
I'm trying to use XPath to select the items which have a facet with
In trying to select elements that have any attributes, the following throws a jQuery
I am trying to select some select box items by their ID in jQuery
I'm trying to select a subgroup of a list where items have contiguous dates,
I am trying to display a multiple select that is disabled and has some

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.