Inserting a Variable String into the javascript prototype expression
Posted
by webzide
on Stack Overflow
See other posts from Stack Overflow
or by webzide
Published on 2010-05-19T23:58:43Z
Indexed on
2010/05/20
0:10 UTC
Read the original article
Hit count: 526
JavaScript
|prototypejs
Dear experts,
Pardon me for giving you a confusing title on this problem. I'm really confused and i don't know how to put it in other words.
So here is what I what to accomplish.
I am making a Custom Javascript Object to store data.
I have automated this process and inserted each instance of the object into an array.
I am making a loop statement to invoke the unique property value of each instance of the object.
When I want to use an expression, the property name of the object would be variable since i don't know which one it is.
Basically I need to incorporate a string value into the prototype expression.
e.g
document.getElementById('text').style."fontsize"=value;
since I cannot do this directly, i thought possibly I could use the eval function:
eval('document.getElementById("text").style.' + buttons[i].cssvalue + '="39px";');
but this still doesn't work.
Can this be fixed or ss there an alternative way to accomplish this?
If there are some unclear stuff, please point out and I will try to elaborate.
Thanks in advance.
© Stack Overflow or respective owner