Click to See Complete Forum and Search --> : Variable substitution


florida
11-07-2003, 06:44 AM
I have a Javascript pop up that works great but I have alot of repetitive parts such as:

this.ID + ', ' + ((j + 2)/2 - 1)


Here is how it looks:


dataOutput = ' onMouseOver = "enterItem (' + this.ID + ', ' + ((j + 2)/2 - 1) + ');" onMouseOut = "exitItem (' + this.ID + ', ' + ((j + 2)/2 - 1) + ');" ';


I tried to put it in a variable and call it but it wont work:

var dataVariable = (this.ID + ', ' + ((j + 2)/2 - 1));

dataOutput = ' onMouseOver = "enterItem (dataVariable);" onMouseOut = "exitItem (dataVariable);" ';

Anyway I can do this??

Khalid Ali
11-07-2003, 07:25 AM
a variable will not "Do" stuff in object oriented owrld, its a property of an object and things that do stuff are typically called functions.
Put the code in a function and then call that function