Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hidden text not displaying

Status
Not open for further replies.

fdgsogc

Vendor
Feb 26, 2004
160
CA
I have hidden some text and am trying to unhide it with an Onclick event. The following test code works just fine for me.
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<table><tr><td>
<div>
<span onClick="ShowTest('test')">Hidden Information:</span>
<div id="test" style="display:none;">
This is a test
</div>
</div>
</td></tr></table>
<SCRIPT LANGUAGE = "JavaScript">
<!--
/* Shows test  */
	function ShowTest(test) {
	document.getElementById('test').style.display = "block";
	}
//stop hiding -->
</SCRIPT>
</body>
</html>
However, when I insert it into my webpage with appropriate variable names, I get nothing. I get no javascript errors, but nor do I have my text unhiding.

Any ideas what would not cause an error in javascript but also not "unhide" an element.

If it helps, my element is between <td> tags.
 
I copied and pasted your code, ran it in IE 6 and Firefox, and it works fine. Do you have XP SP2 with the scripting blocked?

Lee
 
OK. Found the issue. I am using coldfusion and was dynamically creating unique functions by using the ID number of the record. However, my list contains the same record more than once.

What was happening was that I clicked the text and is displayed the hidden text in the first instance of the function name that it found.

Turns out during all of my tests, I never tried it on the first record. Was always trying it on records further down the list that happened to have the same function name.

So I have now created unique function names and am doing fine.

Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top