GetAttr Method (HTMLCONTROL)


10.0A, PLBCMP GUI Only

 

The GetAttr method retrieves low level HTML element attributes from a HTMLCONTROL object. The method gets the requested data from the HTML element that has an id attribute that matches the id parameter. This method uses the following format:

 

[label]

{object}.GetAttr

[GIVING {return}] USING [*Id=]{id}:

 

 

[*Name=]{name}[,[*Flags=]{flags}]

 

Where:

label

Optional. A Program Execution Label.

object

Required. A HTMLCONTROL that is accessed.

return

Optional. A Character String Variable that returns a string from a HTML element depending on the {name} data type.

Id

Required. A Character String Variable or literal that contains the HTML element id attribute.

name

Required. A Character String Variable or literal that identifies the type of data to be retrieved from the HTML element.

flags

Optional. A Numeric Variable or decimal value that specifies a bit mask value that controls the behavior of this method.

Flags Affected: EOS

Note the following:

  1. This method retrieves an attribute value from a HTML element contained in a HTMLCONTROL object.

  2. The EOS flag is set if the returned data string is larger than the DIM variable used to receive the data.

  3. The {id} is a value that determines the HTML element used for data retrieval. The {id} string is matched against the id attribute of the HTML element.

  4. The {name} identifies the type of data retrieved from the HTML element matching the {id} string. Information on HTML element attributes can be found at:

  5.  

    https://www.w3schools.com/html/html_attributes.asp

     

  6. The {name} parameter can be a pre-defined special name or it can be an HTML attribute for the HTML element being accessed.

  7.  

    The pre-defined special name and the HTML attribute names are only returned when the current {flags} value is set to zero (0).

     

    Special

    Comment

    Html

    Html Contents

    Text

    Text Contents

    Class

    Class attribute

    {attr}

    A valid attribute name

     

  8. The {flags} parameter is a bitmask value that forces specialized behaviors for the execution of this method.

  9. The {return} string depends on the {name} data type being requested.

Example of GetAttr Method:

 

For a HTMLCONTROL that contains a HTML element as follows:

 

<input type='text' data-plbenable='on' data-plbevent='change keypress click focus' maxlength=10 id='MyEdit'>

 

This PL/B GetAttr method returns a value using the following instruction:

 

     HtmlControl.GetAttr Giving MyValue Using *ID="MyEdit",*NAME="maxlength" 

 

In this example, the HTML attribute named "maxlength" is retrieved from the HTML element with the id attribute of "MyEdit".

 

The MyValue variable returns a string as follows:

 

     10

 

 

See Also: HTMLControl Methods, Method Syntax



PL/B Language Reference Focus Method (HTMLCONTROL) GetCss Method (HTMLCONTROL)