IHTMLFormElement

IHTMLFormElement


This interface specifies that the contained controls take part in a form.

When programming the form, all control-like elements are added to the form as named items. In addition, these items are exposed through the IHTMLFormElement::item method.

When the focus is on a control in a form, pressing the ESC key once causes the value of the control to revert back to the last value, and pressing the ESC key again resets the form.

If one and only one text box is on a form, pressing ENTER fires the onsubmit event. If the form has a submit button, the button appears with a dark border, indicating that pressing ENTER submits the form.

This element is a block element.

IHTMLFormElement Methods
put_action   get_action   put_dir  
get_dir   put_encoding   get_encoding  
put_method   get_method   get_elements  
put_target   get_target   put_name  
get_name   put_onsubmit   get_onsubmit  
put_onreset   get_onreset   submit  
reset   put_length   get_length  
get__newEnum   item   tags  

IHTMLFormElement::put_action

HRESULT put_action(
    BSTR v
);

Sets the address to be used to carry out the action of the form. If none is specified, the base URL of the document is used.

v
String specifying the address.

The way the data is submitted depends upon the value of the method and encoding properties.

See also get_action

IHTMLFormElement::get_action

HRESULT get_action(
    BSTR *p
);

Retrieves the address to be used to carry out the action of the form. If none is specified, the base URL of the document is used.

p
Address of a variable that receives the address.

The way the data is submitted depends upon the value of the method and encoding properties.

See also put_action

IHTMLFormElement::put_dir

HRESULT put_dir(
    BSTR v
);

Sets the form's direction property. The direction represents the direction of the text on the form.

v
String variable that contains one of the following strings:
"leftToRight" The direction is from left to right.
"rightToLeft" The direction is from right to left.

See also get_dir

IHTMLFormElement::get_dir

HRESULT get_dir(
    BSTR *p
);

Retrieves the direction value for the form. The direction represents the direction of the text on the form.

p
Address of a string variable that receives one of the following strings:
"leftToRight" The direction is from left to right.
"rightToLeft" The direction is from right to left.

See also put_dir

IHTMLFormElement::put_encoding

HRESULT put_encoding(
    BSTR v
);

Sets the mime encoding for the form. This property corresponds to the HTML ENCTYPE= attribute.

v
String specifying the mime encoding. The default is "application/x-www-form-urlencoded". Internet Explorer 4.0 also recognizes "multipart/form-data", which with a POST method is required to submit a file upload to the server

See also get_encoding

IHTMLFormElement::get_encoding

HRESULT get_encoding(
    BSTR *p
);

Retrieves the mime-encoding for the form. This property corresponds to the HTML ENCTYPE= attribute.

p
Address of a variable that receives the mime-encoding. The default is "application/x-www-form-urlencoded". Internet Explorer 4.0 also recognizes "multipart/form-data", which with a POST method is required to submit a file upload to the server

See also put_encoding

IHTMLFormElement::put_method

HRESULT put_method(
    BSTR v
);

Specifies how the form data should be sent to the server, either as GET or POST.

v
String specifying how to send the data. Can be one of these values:
get Append the arguments to the action URL and open it as if it were an anchor.
post Send the data through an HTTP POST transaction.

See also get_method

IHTMLFormElement::get_method

HRESULT get_method(
    BSTR *p
);

Retrieves how the form data should be sent to the server, either as GET or POST.

p
Address of a variable that reeives the send method. Can be one of these values:
get Append the arguments to the action URL and open it as if it were an anchor.
post Send the data through an HTTP POST transaction.

See also put_method

IHTMLFormElement::get_elements

HRESULT get_elements(
    IDispatch **p
);

Retrieves an interface pointer to a zero-based collection of the elements in the form. The pointer provides access to the properties and methods of the elements. The order of the elements in the collection is determined by the HTML source.

p
Address of a variable that receives the interface pointer.

IHTMLFormElement::put_target

HRESULT put_target(
    BSTR v
);

Sets the window or frame to target the contents at.

v
String specifying the name of the target window or frame. Can also be one of the following special values:
_blank Specifies to load the link into a new blank window. This window is not named.
_parent Specifies to load the link into the immediate parent of the document the link is in.
_self Specifies to load the link into the same window the link was clicked in.
_top Specifies to load the link into the full body of the window.

If there is no frame or window that matches the specified target, a new window is opened for the link.

The default value for the target depends upon the URL and site. If the user does not leave the site, the default is _self, but if the user exits to a new site, the default is _top.

See also get_target

IHTMLFormElement::get_target

HRESULT get_target(
    BSTR *p
);

Retrieves the window or frame to target the contents at.

p
Address of a variable that receives the name of the target window or frame, or one of the following special values:
_blank Specifies to load the link into a new blank window. This window is not named.
_parent Specifies to load the link into the immediate parent of the document the link is in.
_self Specifies to load the link into the same window the link was clicked in.
_top Specifies to load the link into the full body of the window.

If there is no frame or window that matches the specified target, a new window is opened for the link.

The default value for the target depends upon the URL and site. If the user does not leave the site, the default is _self, but if the user exits to a new site, the default is _top.

See also put_target

IHTMLFormElement::put_name

HRESULT put_name(
    BSTR v
);

Sets the name of the control, bookmark, or application.

v
String specifying the name.

The name is used to bind the value of the control when submitting a form. The NAME is not the value that is displayed for the button, reset, and submit objects. Submitting the form submits the internally stored value, not the one displayed.

JScript allows the name to be changed at run time. This does change the name in the programming model, in the collection of elements, but does change the name used for submitting elements.

See also get_name

IHTMLFormElement::get_name

HRESULT get_name(
    BSTR *p
);

Retrieves the name of the control, bookmark, or application.

p
Address of a variable that receives the name.

The name is used to bind the value of the control when submitting a form. The NAME is not the value that is displayed for the button, reset, and submit objects. Submitting the form submits the internally stored value, not the one displayed.

JScript allows the name to be changed at run time. This does not change the name in the programming model, in the collection of elements, but does change the name used for submitting elements.

See also put_name

IHTMLFormElement::put_onsubmit

HRESULT put_onsubmit(
    VARIANT v
);

Sets the inline script associated with the onsubmit event for a FORM element. A submit event occurs when a user submits a form (clicks a Submit button).

v
VARIANT structure that contains the script to be set.

See also get_onsubmit

IHTMLFormElement::get_onsubmit

HRESULT get_onsubmit(
    VARIANT *p
);

Retrieves the inline script associated with the onsubmit event for a FORM element. A submit event occurs when a user submits a form (clicks a Submit button).

p
Address of a VARIANT structure that receives the script.

See also put_onsubmit

IHTMLFormElement::put_onreset

HRESULT put_onreset(
    VARIANT v
);

Sets the inline script associated with the onreset event for a FORM element. A reset event occurs when a user resets a form (clicks a Reset button).

v
VARIANT structure that contains the new script.

See also get_onreset

IHTMLFormElement::get_onreset

HRESULT get_onreset(
    VARIANT *p
);

Retrieves the inline script associated with the onreset event for a FORM element. A reset event occurs when a user resets a form (clicks a Reset button).

p
Address of a VARIANT structure that receives the script.

See also put_onreset

IHTMLFormElement::submit

HRESULT submit(
    void
);

Submits the form and fires the onsubmit event.

IHTMLFormElement::reset

HRESULT reset(
    void
);

Simulates a mouse click on a reset button for the calling form.

IHTMLFormElement::put_length

HRESULT put_length(
    long v
);

Sets the number of elements in a collection.

v
Value specifying the length.

This property is read-write on the areas and the options collection for image maps and select boxes, respectively. This allows a developer to shrink the collection.

See also get_length

IHTMLFormElement::get_length

HRESULT get_length(
    long *p
);

Retrieves the number of elements in a collection.

p
Address of a variable that receives the length.

This property is read-write on the areas and the options collection for image maps and select boxes, respectively. This allows a developer to shrink the collection.

See also put_length

IHTMLFormElement::get__newEnum

HRESULT get__newEnum(
     IUnknown **p
);

Retrieves an enumerator interface which can be used to iterate through the form element collection.

p
Address of a variable that receives the IUnknown interface pointer.

IHTMLFormElement::item

HRESULT item(
    VARIANT name,
    VARIANT index,
    IDispatch **pdisp
);

Retrieves an element or a collection from the given collection. The index determines which action to take.

name
Number or string specifying the element or collection to retrieve. If this parameter is a number, the method returns the element in the collection at the given position, where the first element has value 0, the second has 1, and so on. If this parameter contains a string, the method returns a collection of elements, where the value of the NAME or ID= property for each element is equal to the string.
index
Number specifying the position of an element to retrieve. This parameter is used when name is a string. The method uses the string to construct a collection of all elements that have a NAME or ID= equal to the string, then retrieves from this collection the element at the position specified by index.
pdisp
Address of a variable that receives an interface pointer to the element object.

IHTMLFormElement::tags

HRESULT tags(
    VARIANT tagName,
    IDispatch **pdisp
);

Retrieves a collection of all elements in the given collection that have the given HTML tag name.

tagName
String specifying the name of a tag.
pdisp
Address of a variable that receives an interface pointer to the element collection.

This method returns an empty collection if no elements having the given name are found. Use the length property on the collection to determine the number of elements it contains.

© 1997 Microsoft Corporation. All rights reserved. Terms of Use.