Skip to content
Advertisement

Display option data with php and hide the similiar

I’m using php to select data from my database. I’m displaying it in a HTML select option tag. I have 100+ options and I want to hide which is the same as my selected data. For example:

JavaScript

For example the $type variable is “c”. So it displays the option “c” twice. How can I easily hide always the one that I need if I have 100+ option values?

Advertisement

Answer

Manually remove all duplicate option tags with JavaScript and jQuery

JavaScript
JavaScript

Alternative solution

If your given options a, b, c, d are always the same you could setup a „blacklist“ in your PHP code and only echo out the html option element if it‘s not in this blacklist. Is this a possible solution for you?

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement