George <romans5_8@earthlink.net> writes:
[color=blue]
> I tried this as shown below and it worked, however, when I tried to
> put a variable in place of the fixed text string it said that the
> variable is undefined,[/color]
[color=blue]
> Example:
>
> this.mainbox.onclick = function () {
> func(this.id, "str2"); return false; };[/color]
There is no variable this (except "func"). The "this" operator will
refer to the element referred by "this.mainbox" when the onclick event
runs. If you want to refer to "this" object of the assignment inside
the function, you will need to store it as a variable:
var self = this;
this.mainbox.onclick = function () {
func(self.id, "str2"); return false; };
/L
--
Lasse Reichstein Nielsen -
lrn@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'