logo       

cloning nodes vs. creating new() ones: msg#00069

java.enhydra.xmlc

Subject: cloning nodes vs. creating new() ones

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");


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise