Skip to content
Advertisement

HTML select option selected does not work

I want to set the current date by default but it works only on year’s select (the last one).

I wouldn’t like to use javascript in this case. Just html and php.

I have already tried “selected=’selected'” and “autocomplete=off” as shown in different other posts.

Here my code

JavaScript

here the plain HTML when the PHP has been run:

JavaScript

Advertisement

Answer

This is the code you are looking for Remember to use single quotes (‘) when including double quotes inside the PHP echo or else if using double quotes use ” inside the outer double quotes.

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