michelle
09-29-2003, 02:33 PM
I want to change the "text"-property of "example1" using this code, but I have no idea of how I can do this.
I tried this, but it obviously didn't work.
eval(propName+'.text') = newText;
Any thoughts?
// Michelle
<CODE>
var example1 = new addProp('example1');
var example2 = new addProp('example2');
function addProp(text)
{
this.text = text;
this.font = "verdana";
}
function changeProperty(propName, newText) {
//eval(propName+'.text') = newText;
propName.text = newText;
}
<a href="javascript:changeProperty('example1', 'This is the new text')">change text</a>
<br>
<a href="javascript:alert(example1.text);">check value</a>
</CODE>
I tried this, but it obviously didn't work.
eval(propName+'.text') = newText;
Any thoughts?
// Michelle
<CODE>
var example1 = new addProp('example1');
var example2 = new addProp('example2');
function addProp(text)
{
this.text = text;
this.font = "verdana";
}
function changeProperty(propName, newText) {
//eval(propName+'.text') = newText;
propName.text = newText;
}
<a href="javascript:changeProperty('example1', 'This is the new text')">change text</a>
<br>
<a href="javascript:alert(example1.text);">check value</a>
</CODE>