SetAttr Method (HTMLCONTROL)


10.0A, PLBCMP GUI Only

 

The SetAttr method changes low level HTML element attributes in a HTMLCONTROL object. The method sets 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}.SetAttr

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

 

 

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

 

Where:

label

Optional. A Program Execution Label.

object

Required. A HTMLCONTROL that is accessed.

return

Optional. A Numeric Variable that always returns zero.

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 changed in the HTML element.

value

Required. A Character String Variable or literal that has the value string applied to the {name} data type.

flags

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

Flags Affected: OVER, ZERO

Note the following:

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

  2. The ZERO flag is always set TRUE.

  3. The OVER flag is always set FALSE.

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

  5. The {name} identifies the type of data changed in the HTML element matching the {id} string. Information on HTML element attributes can be found at:

  6.  

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

     

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

  8.  

    The pre-defined special name and the HTML attribute names are only used 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

     

  9. The valid values for the {value} parameter depends on the {name} parameter used.

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

  11. The {return} value will always be zero.

Example of SetAttr 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 SetAttr method changes the "maxlength" data value using the following instruction:

 

     HtmlControl.SetAttr Using "MyEdit","maxlength","15"

 

In this instruction, the HTML attribute named "maxlength" is changed to "15" in the HTML element with the id attribute of "MyEdit".

 

 

See Also: HTMLControl Methods, Method Syntax



PL/B Language Reference MakePict Method (HTMLCONTRL SetCss Method (HTMLCONTROL)