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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:38:52+00:00 2026-05-27T09:38:52+00:00

I’m working on a modal multiselect replacement that takes a <select> element and replaces

  • 0

I’m working on a modal multiselect replacement that takes a <select> element and replaces it and it’s <option>s with divs. I am a jQuery novice, and I’ve reached a point now where I have the replacement working perfectly but with a few hiccups in the functionality.

The desired functionality is as follows:

  1. You click "Choose Your Options" which creates a modal dialog
    containing a list of div.options which have been populated using
    .text() from each <option>.

  2. When you choose an option from the modal, it applies a class of
    .selected to the div.option selects the corresponding <option>
    and appends the .text()of that option to an <li> inside a <ul>
    outside of the modal.

  3. When you click on one of the newly generated <li>s, the <li>
    itself should .fadeOut(); and .remove(); while making the
    corresponding <option> unselected.

  4. IF you click "Choose Your Options" after this point, you should be able to select/unselect <option>s and have it reflect accordingly in the <ul>.

As of now, everything happens correclty except for step 4.

I’ve included my code here: jsfiddle.net/zumwalt/HB7HJ/.

Once again, I’m very novice at jQuery/js, so I’m positive that I’ve taken some steps in creating this that don’t make sense.

Any help is greatly appreciated!

  • 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-27T09:38:52+00:00Added an answer on May 27, 2026 at 9:38 am

    There were a couple of issues in your js. I updated your fiddle, check it out: http://jsfiddle.net/HB7HJ/13/

    The first thing I did was to remove this two lines:

    $('ul.multiselect-dropdown-options-'+name+'').empty();
    $('div.option', multiselectmodal).removeClass('selected');
    

    They were removing selected items when calling the modal. I believe we don’t want that ๐Ÿ˜›

    Then I checked if your option was selected or not, adding the option if not, and removing it if did:

    if ($(this).hasClass('selected')) {
        $('ul.multiselect-dropdown-options').append('<li class="dropdown-option drop-down-option-'+value+'">'+optiontext+'<a class="remove-option">x</a></li>');
    } else {
        $('.drop-down-option-' + value).fadeOut().remove();
    }
    

    I also took the following js out from where it was (Inside a click() function, didn’t make much sense):

    $('.dropdown-option-'+value+'').click(function(){
        $(this).fadeOut(500, function () { $(this).remove(); });
        option.removeAttr('selected');
        $('div.option-'+value+'').removeClass('selected');
    });
    

    I’m giving a second look to your code right now, I think it might be improved a bit, i’ll update this if I find something. Anyway, not bad at all for a newbie ๐Ÿ˜€

    Edited after second look ๐Ÿ˜›

    My previous fiddle failed when deleting a row ๐Ÿ™ I set a new working fiddle up: http://jsfiddle.net/HB7HJ/15/

    I refactored the code to make it, imho, a bit more understandable. As Jack the Ripper would say, let’s go by parts:

    1. Removed from the js the HTML that could positively be in the HTML (And added it to the HTML :P).
    2. Removed some unused stuff, like the scroll thing and some useless variables. Maybe you need that in your application, so be careful. Anyway, since that’s not the point of the answer, it just messes the code up.
    3. Added the option value as the id of .options and .dropdown-options. We’ll need them later to check wich option is clicked.
    4. Took the click() events (Modal and options stuff) out from the loop, I think it’s clearer that way. That’s why we need the ids on the options.
    5. Tweaked the .options and .dropdown-options click() event so it will get the id and add/select/remove/unselect the right option according to that id.

    And I think that’s all. I’m sure this code can be vastly improved, but I tried to respect yours so it’d be easier to understand, and I believe it might work as a working base. Let me know if you have further questions ๐Ÿ™‚

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I am reading a book about Javascript and jQuery and using one of the
I have a French site that I want to parse, but am running into
I am currently running into a problem where an element is coming back from

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.