NAME

HTML::DOM::Element::Select - A Perl class for representing 'select' elements in an HTML DOM tree

VERSION

Version 0.054

SYNOPSIS

  use HTML::DOM;
  $doc = HTML::DOM->new;
  $elem = $doc->createElement('select');

  $elem->focus();
  $elem->blur();
  
  # $elem->add(...)    # not yet
  # $elem->remove(...) # implemented

  $elem->options; # a list of 'option' elements

  $elem->name('foo') # set attribute
  $elem->type;       # get attribute
  $elem->tagName;
  # etc.

  $elem->[0]; # first option
  $elem->[1] = $doc->createElement('option');
  $elem->[0] = undef; # deletes it
  delete $elem->[0]; # same

DESCRIPTION

This class implements 'select' elements in an HTML::DOM tree. It implements the HTMLSelectElement DOM interface and inherits from HTML::DOM::Element (q.v.).

ARRAY INTERFACE

You can use a 'select' element as an array reference, to access the individual elements of its options array. @$elem actually does exactly the same thing as @{$elem->options}. See HTML::DOM::Collection::Options for more info on using the array.

METHODS

In addition to those inherited from HTML::DOM::Element and its superclasses, this class implements the following DOM methods:

type
disabled
multiple
name
size
tabIndex

Each of these returns the corresponding HTML attribute. If you pass an argument, it will become the new value of the attribute, and the old value will be returned.

selectedIndex

Returns the index of the selected option. If there is an argument, it selects the specified option and returns the index of the previous selection.

length

Returns the number of options.

form

Returns the form containing this input element.

options

Returns a list of 'option' elements in list context, or an HTML::DOM::Collection::Options object in scalar context.

value

Selects the option with the value given if there is an argument and returns the old value, or simply returns the value if there is no argument.

blur
focus

These each trigger the corresponding event.

In addition, the following methods are provided for compatibility with WWW::Mechanize:

possible_values

This returns an empty list for most input elements, but for checkboxes it returns (undef, $value).

readonly

An alias to readOnly.

form_name_value

Returns a list of two items: (0) the name of the field and (1) the value.

check

Same as $elem->checked(1).

SEE ALSO

HTML::DOM

HTML::DOM::Collection::Options

HTML::DOM::Element

HTML::DOM::Element::Form