Variables in JavaScript Function Arguments (1 Viewer)

ajetrumpet

Banned
Local time
Today, 14:02
Joined
Jun 22, 2007
Messages
5,638
Folks,

This is very basic, but I still cannot get it...

I have this js function in an ASP page:
Code:
function MM_changeProp(objId,x,theProp,theValue) { //v9.0
  var obj = null; with (document){ if (getElementById)
  obj = getElementById(objId); }
  if (obj){
    if (theValue == true || theValue == false)
      eval("obj.style."+theProp+"="+theValue);
    else eval("obj.style."+theProp+"='"+theValue+"'");
  }
}
i don't understand the function, as it was put in automatically by dreamweaver. right now, i am using this onclick event of an image:
Code:
<div id="apDiv19" onclick="MM_changeProp('apDiv7','','backgroundColor','[COLOR="Red"][B]#FFFF00[/B][/COLOR]','DIV')"></div>
the #FFFF00 is the color YELLOW. it is being passed to the theValue argument of the js. what i simply want to do is establish a global variable that will house a color string (like #FFFF00), and then use it in the function argument everytime i need the function. something like this:
Code:
<div id="apDiv19" onclick="MM_changeProp('apDiv7','','backgroundColor',[B][COLOR="Red"]VARIABLE[/COLOR][/B],'DIV')">
i do not know how to do two things:

1) initialize and assign the variable a value, and where to establish it (inside the script tags? in the head? in the body?)

2) how to use the variable as an argument in the function


any help greatly appreciated for this novice. thanks!
 

Users who are viewing this thread

Top Bottom