:: Forum >>

How to access HTML button once created?

Hello,

I know how to add a button at the top of the grid with following code (found in the documentation):

var button = new Active.HTML.BUTTON;
button.setContent("html", "Delete");
button.setEvent("onclick", DeleteRow);
button.setClass("grid","buttonDelete");
document.write(button);

But I don't know how to modify this button when an action is fired on the grid. For example, I would like to modify the button's style when the user clicks a cell.

Thanks for your help !
Allan
Thursday, March 25, 2004
Set your button as a global variable, you can then call it from anywhere in your program.
Thursday, March 25, 2004
var button = new Active.HTML.BUTTON;
...
document.write(button);

function modifyStyle(event){
button.setStyle("border", "1px solid red");
}

function modifyContent(event){
button.setContent("html", "Modified");
button.refresh();
}

var obj = new Active.Controls.Grid;
obj.setEvent("onclick", modifyStyle);
...
document.write(obj);


functions setStyle, setClass and setAttribute apply changes immediately. function setContent requires calling refresh() to repaint the object content.

see also:
http://www.activewidgets.com/documentation/tutorial/html/styles.htm http://www.activewidgets.com/documentation/tutorial/html/attributes.htm

Alex (ActiveWidgets)
Thursday, March 25, 2004
One little thing about reserved words...

Althought Javascript and HTML are very flexible, there are some words you cannot use. You should be able to reference your button by the instance created, and the methods of the original button. But, using the word "button" to name it, is not very bright of yours. Also, do not use tab or any w3c DOM word... I had problems with that :-/ Very sad...
Pablo
Thursday, March 25, 2004

This topic is archived.


Back to support forum

Forum search