HTMLSelectElement.java revision 723:e6268235b2db
1/* 2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * 4 * This code is free software; you can redistribute it and/or modify it 5 * under the terms of the GNU General Public License version 2 only, as 6 * published by the Free Software Foundation. Oracle designates this 7 * particular file as subject to the "Classpath" exception as provided 8 * by Oracle in the LICENSE file that accompanied this code. 9 * 10 * This code is distributed in the hope that it will be useful, but WITHOUT 11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 * version 2 for more details (a copy is included in the LICENSE file that 14 * accompanied this code). 15 * 16 * You should have received a copy of the GNU General Public License version 17 * 2 along with this work; if not, write to the Free Software Foundation, 18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 19 * 20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 21 * or visit www.oracle.com if you need additional information or have any 22 * questions. 23 */ 24 25/* 26 * This file is available under and governed by the GNU General Public 27 * License version 2 only, as published by the Free Software Foundation. 28 * However, the following notice accompanied the original version of this 29 * file and, per its terms, should not be removed: 30 * 31 * Copyright (c) 2000 World Wide Web Consortium, 32 * (Massachusetts Institute of Technology, Institut National de 33 * Recherche en Informatique et en Automatique, Keio University). All 34 * Rights Reserved. This program is distributed under the W3C's Software 35 * Intellectual Property License. This program is distributed in the 36 * hope that it will be useful, but WITHOUT ANY WARRANTY; without even 37 * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 38 * PURPOSE. See W3C License http://www.w3.org/Consortium/Legal/ for more 39 * details. 40 */ 41 42package org.w3c.dom.html; 43 44import org.w3c.dom.DOMException; 45 46/** 47 * The select element allows the selection of an option. The contained 48 * options can be directly accessed through the select element as a 49 * collection. See the SELECT element definition in HTML 4.0. 50 * <p>See also the <a href='http://www.w3.org/TR/2000/CR-DOM-Level-2-20000510'>Document Object Model (DOM) Level 2 Specification</a>. 51 */ 52public interface HTMLSelectElement extends HTMLElement { 53 /** 54 * The type of this form control. This is the string "select-multiple" 55 * when the multiple attribute is <code>true</code> and the string 56 * "select-one" when <code>false</code> . 57 */ 58 public String getType(); 59 60 /** 61 * The ordinal index of the selected option, starting from 0. The value 62 * -1 is returned if no element is selected. If multiple options are 63 * selected, the index of the first selected option is returned. 64 */ 65 public int getSelectedIndex(); 66 public void setSelectedIndex(int selectedIndex); 67 68 /** 69 * The current form control value. 70 */ 71 public String getValue(); 72 public void setValue(String value); 73 74 /** 75 * The number of options in this <code>SELECT</code> . 76 */ 77 public int getLength(); 78 79 /** 80 * Returns the <code>FORM</code> element containing this control. Returns 81 * <code>null</code> if this control is not within the context of a form. 82 */ 83 public HTMLFormElement getForm(); 84 85 /** 86 * The collection of <code>OPTION</code> elements contained by this 87 * element. 88 */ 89 public HTMLCollection getOptions(); 90 91 /** 92 * The control is unavailable in this context. See the disabled 93 * attribute definition in HTML 4.0. 94 */ 95 public boolean getDisabled(); 96 public void setDisabled(boolean disabled); 97 98 /** 99 * If true, multiple <code>OPTION</code> elements may be selected in 100 * this <code>SELECT</code> . See the multiple attribute definition in 101 * HTML 4.0. 102 */ 103 public boolean getMultiple(); 104 public void setMultiple(boolean multiple); 105 106 /** 107 * Form control or object name when submitted with a form. See the name 108 * attribute definition in HTML 4.0. 109 */ 110 public String getName(); 111 public void setName(String name); 112 113 /** 114 * Number of visible rows. See the size attribute definition in HTML 4.0. 115 */ 116 public int getSize(); 117 public void setSize(int size); 118 119 /** 120 * Index that represents the element's position in the tabbing order. See 121 * the tabindex attribute definition in HTML 4.0. 122 */ 123 public int getTabIndex(); 124 public void setTabIndex(int tabIndex); 125 126 /** 127 * Add a new element to the collection of <code>OPTION</code> elements 128 * for this <code>SELECT</code> . This method is the equivalent of the 129 * <code>appendChild</code> method of the <code>Node</code> interface if 130 * the <code>before</code> parameter is <code>null</code> . It is 131 * equivalent to the <code>insertBefore</code> method on the parent of 132 * <code>before</code> in all other cases. 133 * @param element The element to add. 134 * @param before The element to insert before, or <code>null</code> for 135 * the tail of the list. 136 * @exception DOMException 137 * NOT_FOUND_ERR: Raised if <code>before</code> is not a descendant of 138 * the <code>SELECT</code> element. 139 */ 140 public void add(HTMLElement element, 141 HTMLElement before) 142 throws DOMException; 143 144 /** 145 * Remove an element from the collection of <code>OPTION</code> elements 146 * for this <code>SELECT</code> . Does nothing if no element has the given 147 * index. 148 * @param index The index of the item to remove, starting from 0. 149 */ 150 public void remove(int index); 151 152 /** 153 * Removes keyboard focus from this element. 154 */ 155 public void blur(); 156 157 /** 158 * Gives keyboard focus to this element. 159 */ 160 public void focus(); 161 162} 163