Package org.w3c.dom.html

Examples of org.w3c.dom.html.HTMLCollection


        return option.getText();
    }

    public int indexOf(String item)
    {
        HTMLCollection col = selectElem.getOptions();
        int len = col.getLength();
        for(int i = 0; i < len; i++)
        {
            HTMLOptionElement option = (HTMLOptionElement)col.item(i);
            if (option.getText().equals(item))
                return i;
        }
        return -1;
    }
View Full Code Here


        return option.getText();
    }

    public int indexOf(String item)
    {
        HTMLCollection col = selectElem.getOptions();
        int len = col.getLength();
        for(int i = 0; i < len; i++)
        {
            HTMLOptionElement option = (HTMLOptionElement)col.item(i);
            if (option.getText().equals(item))
                return i;
        }
        return -1;
    }
View Full Code Here

        if (currentTarget == selectElem)
        {
            updateItemForm();
            StringBuilder msg = new StringBuilder();
            msg.append("Changed selection: ");
            HTMLCollection col = selectElem.getOptions();
            int len = col.getLength();
            for(int i = 0; i < len; i++)
            {
                HTMLOptionElement option = (HTMLOptionElement)col.item(i);
                msg.append( option.getText() + " (" + option.getSelected() + ") " );
            }
            log(msg.toString());
        }
        else if (currentTarget == removeElem)
        {
            HTMLCollection col = selectElem.getOptions();
            int len = col.getLength();
            HTMLOptionElement[] toRemove = new HTMLOptionElement[len];
            for(int i = 0; i < len; i++)
            {
                HTMLOptionElement option = (HTMLOptionElement)col.item(i);
                if (option.getSelected())
                    toRemove[i] = option;
            }

            for(int i = 0; i < len; i++)
View Full Code Here

    {
        String type = evt.getType();
        EventTarget currTarget = evt.getCurrentTarget();
        if (currTarget == selectElem)
        {
            HTMLCollection col = selectElem.getOptions();
            String str = type + " ";
            for(int i = 0; i < col.getLength(); i++)
            {
                HTMLOptionElement option = (HTMLOptionElement)col.item(i);
                Text item = (Text)option.getFirstChild();
                boolean selected = option.getSelected();
                str += item.getData() + "(" + selected + ") ";
            }
            outText(str);
        }
        else if (currTarget == addItemElem)
        {
            Document doc = itsNatDoc.getDocument();
            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);
        }
        else if (currTarget == removeItemElem)
        {
            if (selectElem.getLength() > 0)
View Full Code Here

        EventTarget currTarget = evt.getCurrentTarget();

        if (currTarget == selItemElem)
        {
            // Invertimos la selecci�n
            HTMLCollection col = selectElem.getOptions();
            int len = col.getLength();
            for(int i = 0; i < len; i++)
            {
                HTMLOptionElement option = (HTMLOptionElement)col.item(i);
                boolean selected = option.getSelected();
                if (selected)
                {
                    option.removeAttribute("selected");
                    i++;
                    i = i % len;
                    option = (HTMLOptionElement)col.item(i);
                    option.setAttribute("selected","selected");
                    break;
                }
            }
        }
View Full Code Here

      parent = parentNode;
      while (parent != null && parent.name != "table") {
        parent = parent.parentNode;
      }
      if (parent == null) return -1;
      HTMLCollection nl = ((HTMLTableElement)parent).getRows();
      for (int i=0;i<nl.getLength();i++) {
        Node n = nl.item(i);
        if (n == this) return i;
      }
        return -1;
    }
View Full Code Here

     * @see org.w3c.dom.html.HTMLTableRowElement#insertCell(int)
     */
    public HTMLElement insertCell(int index)
        throws DOMException {
    CHTMLTdElement tr = new CHTMLTdElement(ownerDocument);
    HTMLCollection nl = getCells();
    if (index == -1) index = nl.getLength();
    if (index < 0 || index > nl.getLength()) {
      throw new DOMException(DOMException.INDEX_SIZE_ERR,index+" > "+nl.getLength()+" ,array index out of bound.");
    }
    if (nl.getLength() == 0) {
      appendChild(tr);
    } else {
        boolean inserted = false;
        Node lastNode = null;
        for (int i=0;i<nl.getLength();i++) {
          Node n = nl.item(i);
          if (i == index) {
            n.getParentNode().insertBefore(tr,n);
            inserted = true;
            lastNode = null;
            break;
View Full Code Here

     *
     * @see org.w3c.dom.html.HTMLTableRowElement#deleteCell(int)
     */
    public void deleteCell(int index)
        throws DOMException {
    HTMLCollection nl = getCells();
    if (index == -1) index = nl.getLength()-1;
    if (index < 0 || index >= nl.getLength()) {
      throw new DOMException(DOMException.INDEX_SIZE_ERR,index+" > "+nl.getLength()+" ,array index out of bound.");
    }
      for (int i=0;i<nl.getLength();i++) {
        Node n = nl.item(i);
        if (i == index) {
          n.getParentNode().removeChild(n);
          break;
        }
      }
View Full Code Here

     * @see org.w3c.dom.html.HTMLTableElement#insertRow(int)
     */
    public HTMLElement insertRow(int index)
        throws DOMException {
        CHTMLTrElement tr = new CHTMLTrElement(ownerDocument);
        HTMLCollection nl = getRows();
        if (index == -1) index = nl.getLength();
        if (index < 0 || index > nl.getLength()) {
          throw new DOMException(DOMException.INDEX_SIZE_ERR,index+" > "+nl.getLength()+" ,array index out of bound.");
        }
        if (nl.getLength() == 0) {
          CHTMLTbodyElement body = new CHTMLTbodyElement(ownerDocument);
          appendChild(body);
          body.appendChild(tr);
        } else {
          boolean inserted = false;
          Node lastNode = null;
          for (int i=0;i<nl.getLength();i++) {
            Node n = nl.item(i);
            if (i == index) {
              n.getParentNode().insertBefore(tr,n);
              inserted = true;
              lastNode = null;
              break;
View Full Code Here

     *
     * @see org.w3c.dom.html.HTMLTableElement#deleteRow(int)
     */
    public void deleteRow(int index)
        throws DOMException {
    HTMLCollection nl = getRows();
    if (index == -1) index = nl.getLength()-1;
    if (index < 0 || index >= nl.getLength()) {
      throw new DOMException(DOMException.INDEX_SIZE_ERR,index+" > "+nl.getLength()+" ,array index out of bound.");
    }
      for (int i=0;i<nl.getLength();i++) {
        Node n = nl.item(i);
        if (i == index) {
          n.getParentNode().removeChild(n);
          break;
        }
      }
View Full Code Here

TOP

Related Classes of org.w3c.dom.html.HTMLCollection

Copyright © 2018 www.massapicom. 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.