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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

JS Show/Hide Div - Filled from DB with ASP 1

Status
Not open for further replies.

Nickman

Programmer
Aug 23, 2001
14
CH
Dont know much of Javascript, so would appreciate if someone could give this a quick lookover and tell me what's wrong.

Desired results: <div> is hidden, is visible with onmouseover and hidden again with onmouseout.

ASP is calling multiple rows:
id=<%=RID%> is ASP-insert of id-number of text
<%=RText%> is ASP-insert of the text

here's the code:
Code:
<script type="text/javascript">
function show (textnr) {
  if (document.textnr)
    document.getElementById(textnr).style.visibility = "visible";
}
function hide (textnr) {
  if (document.textnr)
    document.getElementById(textnr).style.visibility = "hidden";
}
</script>
Here the table is filled with rows from database:
Code:
<td class="even" align="center"><img src="images/auge.gif" width=20 height=20 border=0 onmouseover="show('<%=RID%>')" onmouseout="hide('<%=RID%>')"></td>
<div id="<%=RID%>" style="visibility:hidden; background-color:#dddddd; font-family:Verdana; font-size:8pt; position:absolute; top:135px; left:120px;"><%=RText%></div>

thx for your help
 
I don't think you can use

Code:
  if (document.textnr)

That will always return false as it's checking for an element called textnr and not the content of the variable.

Cheers,
Dian
 
Replace this:
>if (document.textnr)
by
[tt]if (document.getElementById && document.getElementById(textnr) && document.getElementById(textnr).style)
[/tt]
There are more tests than usually necessary as the variable is written in a controlled fashion when the page is created.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top