ksz
03-21-2012, 06:05 PM
Since I don't know the right lingo in stating my question, I was not able to find an answer to my problem on the web.
I am trying to take the value of a string variable and use it as part of ____
I don't know the right lingo to fill in the blank
Here are two examples:
Example 1:
var temp = 'document';
var tooltip = temp.getElementById('tipdiv');
1- Am I correct in my assignment of tooltip above?
meaning tootip= document.getElementById('tipdiv')
2- Can I say that if
temp.getElementById('tipdiv').style.width = '50px'
is the same as
tooltip.style.width = '50px'
also the same as
document.getElementById('tipdiv').style.width = '50px'
Example 2:
var temp = 'style';
var tooltip = document.getElementById('tipdiv');
Am I correct to say:
1- tooltip.temp.width = '50px';
is the same as
tooltip.style.width = '50px';
I have tried the first example in using the string variable in a conditional statement and it seems to work. such as
var temp = 'document'; then used it in
if (temp.all) and it worked
but it didn't work when I set
var temp = 'width'; then used it in assigning value, such as
document.getElementById('tipdiv').style.temp = '50px';
I am trying to learn how to construct a part of or whole statement (I don't think the word "statement' is the correct lingo) such as
document.getElementById('tipdiv').style.width from string variables
Thank you guys
I am trying to take the value of a string variable and use it as part of ____
I don't know the right lingo to fill in the blank
Here are two examples:
Example 1:
var temp = 'document';
var tooltip = temp.getElementById('tipdiv');
1- Am I correct in my assignment of tooltip above?
meaning tootip= document.getElementById('tipdiv')
2- Can I say that if
temp.getElementById('tipdiv').style.width = '50px'
is the same as
tooltip.style.width = '50px'
also the same as
document.getElementById('tipdiv').style.width = '50px'
Example 2:
var temp = 'style';
var tooltip = document.getElementById('tipdiv');
Am I correct to say:
1- tooltip.temp.width = '50px';
is the same as
tooltip.style.width = '50px';
I have tried the first example in using the string variable in a conditional statement and it seems to work. such as
var temp = 'document'; then used it in
if (temp.all) and it worked
but it didn't work when I set
var temp = 'width'; then used it in assigning value, such as
document.getElementById('tipdiv').style.temp = '50px';
I am trying to learn how to construct a part of or whole statement (I don't think the word "statement' is the correct lingo) such as
document.getElementById('tipdiv').style.width from string variables
Thank you guys