Package org.w3c.dom.html

Examples of org.w3c.dom.html.HTMLOptionElement.appendChild()


                {
                    Document doc = getItsNatDocument().getDocument();
                    int pos = Integer.parseInt(posElem.getValue());
                    HTMLOptionElement before = getOptionElement(pos);
                    HTMLOptionElement added = (HTMLOptionElement)doc.createElement("option");
                    added.appendChild(doc.createTextNode(newItem));
                    selectElem.add(added, before);
                    selectElem.setSelectedIndex(pos);
                }
                catch(NumberFormatException ex)
                {
View Full Code Here


                }
                else
                {
                    HTMLOptionElement before = (HTMLOptionElement)getOptionElement(pos);
                    HTMLOptionElement added = (HTMLOptionElement)doc.createElement("option");
                    added.appendChild(doc.createTextNode(newItem));
                    selectElem.add(added, before);
                    selectElem.setSelectedIndex(pos);
                }
            }
            catch(NumberFormatException ex)
View Full Code Here

            HTMLCollection col = selectElem.getOptions();
            HTMLElement option;

            HTMLElement firstOpt = (HTMLElement)col.item(0); // puede ser null
            option = (HTMLElement)doc.createElement("option");
            option.appendChild(doc.createTextNode(Integer.toString(col.getLength())));
            selectElem.add(option, firstOpt);

            option = (HTMLElement)doc.createElement("option");
            option.appendChild(doc.createTextNode(Integer.toString(col.getLength())));
            selectElem.add(option,null);
View Full Code Here

            option = (HTMLElement)doc.createElement("option");
            option.appendChild(doc.createTextNode(Integer.toString(col.getLength())));
            selectElem.add(option, firstOpt);

            option = (HTMLElement)doc.createElement("option");
            option.appendChild(doc.createTextNode(Integer.toString(col.getLength())));
            selectElem.add(option,null);
        }
        else if (currTarget == removeItemElem)
        {
            if (selectElem.getLength() > 0)
View Full Code Here

   */
  public void addElement( String element )
  {
    Node text = htmlDoc.getBody().getFirstChild().cloneNode( true );
    HTMLOptionElement option = (HTMLOptionElement)htmlDoc.createElement( "OPTION" );
    option.appendChild( text );
    option.getFirstChild().setNodeValue( element );
    selectElement.appendChild( option );
  }

  /**
 
View Full Code Here

  public void insertElement( String element, int index )
  {
    if ( index <= getSize() ) {
      HTMLOptionElement option = (HTMLOptionElement)htmlDoc.createElement( "OPTION" );
      Node text = htmlDoc.getBody().getFirstChild().cloneNode( true );
      option.appendChild( text );
      option.getFirstChild().setNodeValue( element );
      selectElement.insertBefore( option, selectElement.getChildNodes().item( index - 1 ) );
    }
    else {
      addElement( element );
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.