NAME
HTML::DOM::Element::Input - A Perl class for representing 'input' elements in an HTML DOM tree
SYNOPSIS
use HTML::DOM;
$doc = HTML::DOM->new;
$elem = $doc->createElement('input');
$elem->setAttribute('type' => 'text');
$elem->click();
$elem->blur();
# etc.
$elem->checked(1) # set attribute
$elem->type; # get attribute
$elem->tagName;
# etc.
DESCRIPTION
This class implements 'input' elements in an HTML::DOM tree. It implements the HTMLInputElement DOM interface and inherits from HTML::DOM::Element (q.v.).
METHODS
In addition to those inherited from HTML::DOM::Element and its superclasses, this class implements the following DOM methods:
- defaultValue
- defaultChecked
- accept
- accessKey
- align
- alt
- disabled
- maxLength
- name
- readOnly
- size
- src
- tabIndex
- type
- useMap
-
Each of these returns the corresponding HTML attribute (the 'value' and 'checked' attributes in the case of
defaultValue
anddefaultChecked
, respectively). If you pass an argument, it will become the new value of the attribute, and the old value will be returned. - form
-
Returns the form containing this input element.
- checked
- value
-
These methods allow one to change the state of the input field. The change is not reflected in the HTML attributes. These will be called with the values of
defaultValue
anddefaultChecked
when the form'sreset
method is invoked.The
value
method behaves differently if the calling package is HTML::Form, HTML::Form::Input or WWW::Mechanize. For checkboxes, the return value will be undef if the box is not checked. With an undef argument the box will be unchecked. If an argument is given that is the same as the 'value' attribute, the box will be checked. If any other argument is passed, it will die. If the 'type' attribute is 'button' or 'reset,'value
will simply return. - blur
- focus
- select
- click
-
Each of these triggers the corresponding event. The
click
method can take three arguments, all optional: (0) the form, (1) the x-coordinate where the mouse supposedly clicked and (2) the y-coordinate.
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)
. - form_name_value
-
Returns a list of two items: (0) the name of the field and (1) the value.
- file
-
An alias for
value
- filename
-
This get/sets the filename reported to the server during file upload. This attribute defaults to the value reported by the file() method.
- headers
-
Returns an empty list (for now).
- content
-
This get/sets the file content provided to the server during file upload. This method can be used if you do not want the content to be read from an actual file.