logo

New Response

« Return to the blog entry

You are replying to:

  1. Dot notation does not work in all browsers if the attribute does not already exist in the element node, whereas setAttribute() will create an attribute node if one does not exist.

    For a <select> you need to create <option> nodes. These will actually contain the values/text as attributes. So you'd create a <select> node on the document, then, for each option:

    create the <option> node using createElement()

    set the value attribute using setAttribute()

    fix it to the <select> node using appendChild()

    The text would be handled using createTextNode, and that node would be glued to the <option> using appendChild() as well.

Your Comments

Name:
E-mail:
(optional)
Website:
(optional)
Comment: