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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T15:18:39+00:00 2026-05-13T15:18:39+00:00

I have a set of values that are present on the page loading: eg

  • 0

I have a set of values that are present on the page loading:
eg [1193,1184,2372].

I have a dropdownchecklist which can take a single value like so
$(“.ddl”).dropdownchecklist().val(1193);

When I rebind the dropdownchecklist this selects the value correctly. However I’ve tried passing my array containing multiple values to the val() method and that doesn’t select the values. I kind of expected this. I’m not sure how to best go about preselecting.

I’ve tried iterating my array to build an filter attribute to apply as the following:
$(“.ddl [value*=’1184′][value*=’9067′][value*=’14841′]”).attr(‘selected’,’selected’);

but this doesn’t work. I don’t want to have to iterate all the options in the ddl and set them to selected if they match as there are hundreds of options and this won’t be good performance wise, especially if there are only 2 options to be preseleted.

Any ideas?

  • 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-05-13T15:18:39+00:00Added an answer on May 13, 2026 at 3:18 pm

    Create a string of the selected ones to create the jQuery selector string and put it into the .find() function:

    var str = '';
    var arrLength = selectedArray.length;
    $.each(selectedArray, function(i){
       str += 'option[value*='+selectedArray[i]+']';
       if((i+1) != arrLength){
         str += ', ';
       }
    });
    
    $('.ddl').find("option[value*='1184'], option[value*='9067'], option[value*='14841']")
         .attr('selected','selected'); 
    

    Also note, when comparing a drop down with a value, you’re looking for the option element in the select, not the select element itself.

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

Sidebar

Related Questions

I have a set of values that I'm pushing into an array in the
I have a large set of values V, some of which are likely to
I have set up an update query which will update values entered into text
I have an ASP.NET page (WebForm) on which I set the content of a
I have a PHP-generated page which is displaying some data about a set of
Problem: I have a value that is set in $record, for instance 1.69. Then
I have a stored procedure that says update table1 set value1 = 1 where
I have a dataset that i am trying to set the default value as
I have a function that I set custom key and value to it and
public void test(Object obj){ //Here i have to set the values of the obj

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.