cloning nodes vs. creating new() ones
Matthew Hixson <[email protected]> Mon, 15 Sep 2003 11:03:29 -0700
| Newsgroups | gmane.comp.java.enhydra.xmlc |
|---|---|
| Message-ID | <[email protected]> |
In my HTML I have a dropdown list with one teacher option. I'm using
cloneNode() to create another <option> element and calling cloneNode()
on that teacher's <option> to create the text that goes <option>right
here</option>. I'm using cloneNode() because I don't know how to go
about creating a new object that implements HTMLOptionElement. Is the
way I'm doing this how its supposed to be done, by using the w3c API,
or is there a better way to instantiate new XMLC specific objects and
add them to the HTMLSelectElement?
Thanks,
-M@
HTMLSelectElement teacherDropdown = form.getElementTeacherDropdown();
HTMLOptionElement teacher1 = form.getElementTeacherOption();
HTMLOptionElement teacher2 = (HTMLOptionElement)
teacher1.cloneNode(false);
teacher2.appendChild(teacher1.getFirstChild().cloneNode(false));
teacher2.getFirstChild().setNodeValue("Mr. Snyde");
teacher2.setValue("2");