Skip to content
Advertisement

Make select default option from database

i have issue with making default text in my select. (option list). So, my option is storage in database. Like varchar Test Option

Now if i make like this in my code

JavaScript

it working, but in my list be two same values then. my full code.

JavaScript

My code for function q and pick value from database (all value from option is from database)

JavaScript

picture what explain situation more. enter image description here

any idea how to solve it ? all help will be appreciated

Advertisement

Answer

Well, the real situation is that you are fetching an array but you want that the option won’t be printed. Then, you first have the selected option, that is:

JavaScript

Then the only thing that you have to do is that when you fetch the array, if the option is equal to the selected option won’t be printed so:

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