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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T02:16:15+00:00 2026-06-01T02:16:15+00:00

I have a dropdown list and a select list. Both contain quite a few

  • 0

I have a dropdown list and a select list. Both contain quite a few identical items. Basically I am setting the selected value of the dropdown based on the list item index that has been clicked on.

Code for this is:

$('.dropdown-list li').click(function(){
    $('#edit-type option').removeAttr('selected', 'selected');
    var listvalue = $(this).index();
    $('#edit-type option').eq(listvalue).attr('selected', 'selected');
});

This works but its quite slow. There is a 3/4 second delay before the dropdown option becomes selected.

Is there a faster way to do this?

EDIT:

<select id="edit-type" name="type" class="form-select" style="display: none; ">
<option value="All">- Any -</option>
<option value="171">item Name 1 </option>
<option value="172" selected="selected">item Name 2</option>
</select>

<ul class="dropdown-list">
<li><div><span>item Name 1</span></div></li>
<li class="selected"><div><span>item Name 2</span></div></li>
</ul>

My reason for doing this is so I can create a styled dropdown.

Thanks
Robert

  • 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-01T02:16:17+00:00Added an answer on June 1, 2026 at 2:16 am

    You probably have lots of items in the list if it’s that slow. The fastest way should be directly setting the selected index:

    $('.dropdown-list li').click(function(){
        var oDDL = $('#edit-type');
        if (oDDL.length > 0)
            oDDL[0].selectedIndex = $(this).index();
    });
    

    In case you really have lots of items it also much better to use .on() which will create single handler behind the scenes instead of handler for each list item:

    $('.dropdown-list').on('click', 'li', function() {
        //...
    });
    

    Live test case.

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

Sidebar

Related Questions

So I have a dropdown list <select id=theSelectId> <option value=volvo>Volvo</option> <option value=saab>Saab</option> <option value=mercedes>Mercedes</option>
On my html page I have a dropdown list: <select name=somelist> <option value=234234234239393>Some Text</option>
Suppose I have a drop-down list like: <select id='list'> <option value='1'>Option A</option> <option value='2'>Option
I have a dropdown list that stores name/value pairs. The dropdown appears in each
I have a dropdown select list on my page of class=TypeFilter. I have a
I have multiple dropdown list for same select list in look and want to
I have a drop down list where users can select a theme for the
I have dropdown list control in one of my application and when I add
I have a dropdown list (FK) which I would like to set and display
I have a dropdown list containing the days of the week - Monday to

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.