Please see my comment to the question.
The first bug I can see is using
val
. It means that you try to set the value of the
value
property of the element
option
. You certainly can do it, but this property has no significance to this element, in terms of visible HTML DOM. It can be used to pass data from a selected option to the script, and can be any object. You don't have to use it, can use any other new property; it's important to pass data from HTML which you don't write but create on the fly. In other words, you don't do anything you have to.
You probably need to add two to four things: the option text, and, optionally, one or more of the following attributes: id, value and selected. Please see:
option — HTML | MDN[
^].
The simplest way to add the option text is using
innerHTML
of this (or any other elements). In your simple case, this is enough. On top of that, you can add attributes, which can be done by using the save very
val
(for
value
) and, say, jQuery
.attr()
:
.attr() | jQuery API Documentation[
^].
Basically, that's all.
—SA