Robdel12 / DropKick

A JavaScript plugin for creating beautiful, accessible, and painless custom dropdowns.

Home Page:http://dropkickjs.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Hiding the Selected Option From the Dropdown List

benlevydesign opened this issue · comments

Version of Dropkick:

2.1.7

Expected Behavior

I would like to be able to hide the selected option from the list of the other options so it only shows once.
For example, if yes is the selected option, I only want the "disabled placeholder" and "no" to show.
selectoptions

Actual Behavior

hideselected

Hey @benlevywebdesign! Would you be able to apply a class to the selected option that hides it?

@Robdel12 I updated my question.

@benlevywebdesign Setting .dk-option-selected to display: none; should resolve the issue.

@acemir I want the selected option to stay. The selected option also shows up in the choices below the disabled placeholder option.

If the choices are: Choose One(placeholder), Yes, No, Maybe and the selected choice is "Yes" then I don't want to see "Yes, Choose One, Yes, No, Maybe".

See my first comment above.

Oh wait, that's actually interesting. How does that happen? You're getting a duplicate of the selected option?

That looks to be the expected outcome I think.
image.

The selected part of dropkick should show the selected option. And then the list should have the selected option highlighted.

It's on forms when I get the selected value from the database. See code below:
dropkick

<select class="selectoptions_ma" id="imageuploaded" name="imageuploaded">
<option selected value='<?php echo $imageuploaded ?>'> <?php echo ($imageuploaded == '1') ? Yes : No ?></option>
<option value="" disabled="disabled">Image Uploaded?</option>
<option value="1">Yes</option>
<option value="0">No</option>
</select>

How would I either make the selected value be from the order of the list or take it out and only show the non selected options below the placeholder?

dropkick2

or

40929904-f6cd1900-67da-11e8-8a63-c91f806f2cfb

Ahh, I see what you're going for now. From the example code you gave I'd write the select like this:

<select>
  <option value="" disabled="disabled">Image Uploaded?</option>
  <option <?php echo ($imageuploaded == '1') ? 'selected' : '' ?> value="1">Yes</option>
  <option <?php echo ($imageuploaded == '0') ? 'selected' : '' ?> value="0">No</option>
</select>

That will have two selectable options in the list and it will select the right one given the value from the DB ($imageuploaded).