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!

strColorCell ?

Status
Not open for further replies.

wuzzle

Programmer
Dec 20, 2000
75
CA
Ok, this code states that the link to the current page is hilighted. I still want it to be hilighted, but I don't want the cell to be blue. I want the text to be red.

Here is the first part:

<%
function strColorCell (strCellURL)
'Purpose: For Navbars -- bolds the cell background if it contains a link to the current page.
'Arguments:
'strCellURL -- a unique portion of the URL to which this cell links.
'Returns: an HTML string which either colors the cell's background, or leaves it alone.
dim strPresentURL
strPresentURL=Request.ServerVariables(&quot;PATH_INFO&quot;)
if instr (1,strPresentURL,strCellURL,1)>0 then
strColorCell=&quot; bgcolor=#999CC&quot;
else
strColorCell=&quot;&quot;
end if
end function
%>

And here is where it's applied:

<td <%=strColorCell(&quot;/hosting/default.asp&quot;)%>>
<font size=1 face=&quot;tahoma,arial&quot;><b>
<a href=&quot;/hosting/&quot; class=textBlack onMouseOver=&quot;this.className='textRed'&quot; onMouseOut=&quot;this.className='textBlack'&quot;>Website Hosting</a>
</b></font>
</td>

Any suggestions for me? I tried strColorText...didn't work.
Thanks!

 
I think this may be due to Request.ServerVariables(&quot;PATH_INFO&quot;) not holding what you are expecting. There is nothing wrong with the script - I have got it to work, just changing the value that is passed into the function (ie &quot;/hosting/default.asp&quot;).

To debug this, add the line:

strColorCell = &quot; &quot; &amp; Request.ServerVaraibles(&quot;PATH_INFO&quot;)

immediately before the end function line. Refresh your page and then view source. You should see the variable contents written to the table <td> tag. Then, you can tell whether the InStr function will return 0 or not. I think it is returning 0, so the value of the function is &quot;&quot; - set in the else statement.

This is the page that works for me:

<html>
<head>
<title>Testing bgcolor in table cell</title>
<%
Private function strColorCell (strCellURL)
'Purpose: For Navbars -- bolds the cell background if it contains a link to the current page.
'Arguments:
'strCellURL -- a unique portion of the URL to which this cell links.
'Returns: an HTML string which either colors the cell's background, or leaves it alone.
dim strPresentURL
strPresentURL=Request.ServerVariables(&quot;PATH_INFO&quot;)

if instr(strPresentURL,strCellURL)>0 then
strColorCell=&quot; bgcolor=#999CC&quot;
else
strColorCell=&quot;&quot;
end if

'strColorCell = Request.ServerVariables(&quot;PATH_INFO&quot;)

end function
%>
</head>
<body>
<table border=1>
<tr>
<td<%=strColorCell(&quot;/sdw/test6.asp&quot;)%>>
<font size=1 face=&quot;tahoma,arial&quot;><b>
<a href=&quot;/hosting/&quot; class=textBlack onMouseOver=&quot;this.className='textRed'&quot; onMouseOut=&quot;this.className='textBlack'&quot;>Website Hosting</a>
</b>
</font>
</td>
</tr>
<tr>
<td><a href=&quot; <tr>
</table>

</body>
</html>

where the path /sdw sits in the default web folder (
To do my debug suggestion, just remove the comment marker from the line.

Simon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top