Adding an ID attribute to a HATS component

Off
Strongback Consulting

In JavaScript and CSS its very helpful for an element to have an id attribute (not just a class attribute).

For those of you not in the know, the id attribute should be unique across the entire HTML. Only one element should have value of that id. Class attributes allow HTML elements to be grouped and formatted similarly.

For example in the following HTML,

=”myClassid=”myIdvalue=”Click Me” type=”button” name=”myName”>

You can access this button with the Javascript using document.getElementsByNames(‘myName’), which returns an array. The better way is to use getElementById(‘myId’), which gets only that element.

HATS Components by default do not write out an id attribute, but rather only a name attribute. You can ‘hack’ this by adding the following in the ‘Style’ settings of the widget (after all style parameters:

” id=”myId

The first double quotation mark ends the style
attribute in the HTML. Then the ID attribute is written with its value, but NO closing double quotation mark. The JSP code will add the ending double quotation mark for you.

Now, I had problems where the GUI would change my initial double quotation mark in to a single quote. That will not work. In this case you will need to go into the source code and edit the component manually.

Comments are closed.

Strongback Consulting