Click to See Complete Forum and Search --> : passing a property to a function


ankaa
03-04-2003, 06:44 PM
given an objects property as a string (for example, 'document.all.divtest.background'), how can this be passed into a function whereas the function can get the current value, and set the property to a new value?

Jona
03-04-2003, 06:52 PM
You mean like if(shooter.bgColor='red'){alert()} ?

Of course, that'd be where, <table name="shooter"> exists..

ankaa
03-04-2003, 07:21 PM
No

I mean ...

function something(prop, nvalue) {
prop=nvalue;
}

something('document.all.div1.style.background', 'red');

cheese_stinks
03-04-2003, 07:28 PM
pass document.all.div1.style and then set prop.background in the function

Jona
03-04-2003, 07:39 PM
Did you try that code?

ankaa
03-04-2003, 07:47 PM
pass document.all.div1.style and then set prop.background in the function

thats what i'm trying to avoid...

Did you try that code?

if you're talking about the code i just posted, yes.