Click to See Complete Forum and Search --> : Using variable in table.


quangnhan
03-13-2003, 09:21 PM
Hi anybody.

I want to control (display or hide) any row in one table as follow...


<script language= "javascript">

document.write("<TABLE border=" + "\"" +"0" + "width="+ "\"" + "100%" + "\""+">")
document.write("<TR id ="+ "\"" +"col1" + "\"" +"><td>")
document.write ("Menu 1")
document.write("</td></TR>")
document.write("<TR id ="+ "\"" +"col2" + "\"" +"><td>")
document.write ("Menu 2")
document.write("</td></TR>")
document.write("</TABLE>")

col1.style.display ="none"
</script>


In this scipt, i use: col1.style.display ="none" to hide col1 is OK. Now, I would like to use a variable (ex.. temp) instead of "col1" how can i do that?

khalidali63
03-13-2003, 09:41 PM
Here is one way of doing this

var obj = eval(temp+'.style')
obj.display = "none"

Will have the same effect

Cheers

Khalid