setDOMAttribute(element, attribute, value )
This function sets a DOM/HTML property or attribute on an element. The DOM is the browser’s Document Object Model that represents all of the HTML on a page.
Parameters:
element – the reference to a DOM element
attribute – the HTML attribute to set
value – the value to assign to the attribute specified
Examples:
In this example, we will set the value attribute of a textbox to “Please Enter your name”.
setDOMAttribute("TextBox1", "value", "Please Enter your name");
The line of code above is equivalent to:
changeElementValue("TextBox1", "Please Enter your name");
In the next example, we will disable a textbox so users will not be able to type any information in that textbox. In this case, we assign an onclick event handler function to a button that changes the “disabled” attribute on an input field to true.
// get the button object
var button = getObj("my_button");
// assign an onclick handler function to the button
button.onclick = function()
{
setDOMAttribute("I_6_20", "disabled", true);
}
Other DOM properties such as size, maxlength, align, etc. can be changed as well depending on the type of DOM element.