CodeChargeMVP
Posts: 473
|
| Posted: 07/26/2010, 3:40 AM |
|
Hello,
I´m trying to use the eval function on javascript this way:
function activate(object)
{
eval(object).style.textDecoration = "underline";
}
<a href="{Link2_Src}" id="ForgoYourPassword" onclick="OpenPop_UpList1();return false;"><h6 id="a1" onMouseOver="activate('a1');">¿Forgot you password?</h6></a></td>
The calling to the function activate works fine, but the eval line inside activate funtion
doesn´t made what was suppossed to do.
According to Javascript theory I can use eval() function to send it an object and
then get access to the propertys of that object, but it doesn´t work.
¿Any suggestion?
¿Does anybody knows another way to convert an String Object to Type object instead of eval?
Thank you very much in advance.
_________________
Best Regards
Entrepeneur | NT Consultant
|
 |
 |
hidran
Posts: 29
|
| Posted: 07/27/2010, 9:50 AM |
|
In your example there isn't any object whose name is a1
This example works:
function activate(object)
{
var a1=document.getElementById(object);
var s=object+'.style.background';
eval(s+'= "#ff0000"');
}
as there is an object called a1
In any case, you could just do this:
var a1=document.getElementById(object);
if(a1){
a.style.textDecoration="underline";
}
Tag <h1> doesn't not support text-decoration property
}
|
 |
 |
CodeChargeMVP
Posts: 473
|
| Posted: 07/28/2010, 6:06 AM |
|
Hello hidran,
Thanks for your shot,
On my example the object is the text,
realise than I give it an id="a1",
When you study deeper and harder javascript theory the first html object than you learn is the text,
Yes I think so, I´d be more specific CodeCharge html tags doesn´t support that property, but it supported on professional javascript books.
anyways I´ll try your solution and get back with some feedback.
Quote hidran:
In your example there isn't any object whose name is a1
This example works:
function activate(object)
{
var a1=document.getElementById(object);
var s=object+'.style.background';
eval(s+'= "#ff0000"');
}
as there is an object called a1
In any case, you could just do this:
var a1=document.getElementById(object);
if(a1){
a.style.textDecoration="underline";
}
Tag <h1> doesn't not support text-decoration property
}
_________________
Best Regards
Entrepeneur | NT Consultant
|
 |
 |
CodeChargeMVP
Posts: 473
|
| Posted: 07/29/2010, 1:21 AM |
|
great work hydran,
that was the solution 
thank you very much.
_________________
Best Regards
Entrepeneur | NT Consultant
|
 |
 |
CodeChargeMVP
Posts: 473
|
| Posted: 07/29/2010, 1:38 AM |
|
further solution:
window.document.getElementById("a1").style.textDecoration = "underline" or "none";
Since I include the text tags inside the link I can use the text link as an object and modify his
showing in the way I like.
_________________
Best Regards
Entrepeneur | NT Consultant
|
 |
 |
|