Click here to Skip to main content
16,011,383 members
Home / Discussions / Web Development
   

Web Development

 
GeneralRe: Javascript menu Pin
Cyrad27-Jan-02 9:19
Cyrad27-Jan-02 9:19 
GeneralCalling js functions across frame boundaries Pin
Wolfram Steinke5-Jan-02 18:19
Wolfram Steinke5-Jan-02 18:19 
GeneralSocket programming in ASP Pin
Lali3-Jan-02 18:54
Lali3-Jan-02 18:54 
GeneralASP.NET Pin
Matt.W.2-Jan-02 16:20
Matt.W.2-Jan-02 16:20 
GeneralHTML encapsulation from code Pin
hforbess30-Dec-01 11:23
hforbess30-Dec-01 11:23 
GeneralRe: HTML encapsulation from code Pin
Philip Patrick1-Jan-02 2:37
professionalPhilip Patrick1-Jan-02 2:37 
QuestionActiveX control or C++ library to create VCARDs? Pin
Uwe Keim22-Dec-01 5:38
sitebuilderUwe Keim22-Dec-01 5:38 
GeneralWeird JavaScript Problem Pin
Derek Lakin20-Dec-01 19:59
Derek Lakin20-Dec-01 19:59 
I've just written a JavaScript collapsible table of contents for my website. It works on the basis of using the display style for the child rows.

I use Macromedia DreamWeaver to manage my site, so the table of contents is a library item that is then added to a template. The template is applied to all pages (except the home page), so the code is exactly the same on all pages and looks like this:
<table width="125" border="0" cellspacing="0" cellpadding="0" bgcolor="#FF0000">
  <tr> 
    <td><a href="..\index.htm" class="ParentMenuItem">Home</a></td>
  </tr>
  <tr> 
    <td><a href="..\about.htm" class="ParentMenuItem">About</a></td>
  </tr>
  <tr> 
    <td><a href="..\contact.htm" class="ParentMenuItem">Contact</a></td>
  </tr>
  <tr> 
    <td id="News" class="ParentMenuItem" onClick="
		var rowIDs = new Array ();
		rowIDs[0] = Salamander;
		rowIDs[1] = Headlines;
		showHideRows (News, rowIDs, 2);">+News</td>
  </tr>
  <tr id="Salamander" style="display: none;"> 
    <td><a href="..\news.htm" class="SubMenuItem">Salamander</a></td>
  </tr>
  <tr id="Headlines" style="display: none;"> 
    <td><a href="..\headline.htm" class="SubMenuItem">Headlines</a></td>
  </tr>
  <tr> 
    <td> </td>
  </tr>
  <tr> 
    <td id="Products" class="ParentMenuItem" onClick="
		var rowIDs = new Array ();
		rowIDs[0] = CButtonSSL;
		rowIDs[1] = CListCtrlSSL;
		rowIDs[2] = CTabCtrlSSL;
		rowIDs[3] = WinDiff;
		showHideRows (Products, rowIDs, 4);">+Products</td>
  </tr>
  <tr id="CButtonSSL" style="display: none;"> 
    <td><a href="..\products\cbuttonssl.htm" class="SubMenuItem">CButtonSSL</a></td>
  </tr>
  <tr id="CListCtrlSSL" style="display: none;"> 
    <td><a href="..\products\clistctrlssl.htm" class="SubMenuItem">CListCtrlSSL</a></td>
  </tr>
  <tr id="CTabCtrlSSL" style="display: none;"> 
    <td><a href="..\products\ctabctrlssl.htm" class="SubMenuItem">CTabCtrlSSL</a></td>
  </tr>
  <tr id="WinDiff" style="display: none;"> 
    <td><a href="..\products\windiff.htm" class="SubMenuItem">WinDiff Add-in</a></td>
  </tr>
  <tr> 
    <td colspan="2" id="Services" class="ParentMenuItem" onClick="
		var rowIDs = new Array ();
		rowIDs[0] = Software;
		rowIDs[1] = WebDesign;
		rowIDs[2] = Graphics;
		showHideRows (Services, rowIDs, 3);">+Services</td>
  </tr>
  <tr id="Software" style="display: none;"> 
    <td><a href="..\services\software.htm" class="SubMenuItem">Software</a></td>
  </tr>
  <tr id="WebDesign" style="display: none;"> 
    <td><a href="..\services\webdes.htm" class="SubMenuItem">Web Design</a></td>
  </tr>
  <tr id="Graphics" style="display: none;"> 
    <td><a href="..\services\graphics.htm" class="SubMenuItem">Graphics</a></td>
  </tr>
  <tr> 
    <td><a href="..\support.htm" class="ParentMenuItem">Support</a></td>
  </tr>
  <tr> 
    <td> </td>
  </tr>
  <tr> 
    <td><a href="..\clients.htm" class="ParentMenuItem">Clients</a></td>
  </tr>
  <tr> 
    <td><a href="..\projects.htm" class="ParentMenuItem">Projects</a></td>
  </tr>
</table>


The showHideRows is in a separate file, contents.js which is referenced in the page body in the template using the following:
<SCRIPT Language="JavaScript" src="..\_private\contents.js"></SCRIPT>


The content of the javascript is as follows:
function showHideRows (parentRow, rowIDs, rowCount) {
	var strInnerText = parentRow.innerText;
	for (i = 0; i < rowCount; i++) {
		if (strInnerText.charAt (0) == '+') {
			rowIDs[i].style.display = "";
		}
		else {
			rowIDs[i].style.display = "none";
		}
	}
	var strLabel = strInnerText.slice (1);
	if (strInnerText.charAt (0) == '+') {
		parentRow.innerText = '-' + strLabel;
	}
	else {
		parentRow.innerText = '+' + strLabel;
	}
}


The problem is that for two of the pages, the 'Products' part of the menu does not work, because one of the IDs is not the actual row it is supposed to be and so trying to change it's style fails in the function. Rather than being a element with it's multitude of properties, it has two properties, length and _enum. The pages in question are Products\CButtonSSL and Products\CTabCtrlSSL.

If it works for all the other pages using exactly the same code, why doesn't it work for these two?Confused | :confused:

Derek Lakin.

I wish I was what I thought I was when I wished I was what I am.

Salamander Software Ltd.
GeneralRe: Weird JavaScript Problem Pin
Philip Patrick23-Dec-01 7:15
professionalPhilip Patrick23-Dec-01 7:15 
GeneralRe: Weird JavaScript Problem Pin
Derek Lakin25-Dec-01 22:24
Derek Lakin25-Dec-01 22:24 
Generalquestion Pin
Steve L.19-Dec-01 13:19
Steve L.19-Dec-01 13:19 
GeneralMmm.... interesting question Pin
Philip Patrick1-Jan-02 9:50
professionalPhilip Patrick1-Jan-02 9:50 
GeneralRe: question Pin
Paul Watson19-Jan-02 8:30
sitebuilderPaul Watson19-Jan-02 8:30 
Generalsecurity of .ocx Pin
marutis16-Dec-01 19:00
marutis16-Dec-01 19:00 
Generalhelp....Using MS Index Server Pin
12-Dec-01 10:00
suss12-Dec-01 10:00 
Generalneed help w/ IIS 5.0 and Access Database Pin
12-Dec-01 8:41
suss12-Dec-01 8:41 
GeneralRe: need help w/ IIS 5.0 and Access Database Pin
Jon Sagara12-Dec-01 8:47
Jon Sagara12-Dec-01 8:47 
GeneralRe: need help w/ IIS 5.0 and Access Database Pin
Jon Sagara12-Dec-01 8:55
Jon Sagara12-Dec-01 8:55 
GeneralRe: need help w/ IIS 5.0 and Access Database (one more time) Pin
Jon Sagara12-Dec-01 8:58
Jon Sagara12-Dec-01 8:58 
GeneralRe: need help w/ IIS 5.0 and Access Database Pin
Jason Jystad13-Dec-01 5:36
Jason Jystad13-Dec-01 5:36 
QuestionMS Date and Time Picker. Bug? Pin
11-Dec-01 0:13
suss11-Dec-01 0:13 
QuestionScriplet and C# in asp.net, No integration??? Pin
ng ks9-Dec-01 23:03
ng ks9-Dec-01 23:03 
QuestionHow to use Split in ASP Pin
Gopi Krishna9-Dec-01 14:33
Gopi Krishna9-Dec-01 14:33 
AnswerRe: How to use Split in ASP Pin
Jon Sagara9-Dec-01 14:55
Jon Sagara9-Dec-01 14:55 
GeneralHTML executing DLLs Pin
john john mackey7-Dec-01 11:27
john john mackey7-Dec-01 11:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.