Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 06-11-2003, 08:21 PM   PM User | #1
stereohi
New Coder

 
Join Date: Jul 2002
Location: Chattanooga, Tennessee
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
stereohi is an unknown quantity at this point
Exclamation script error help

Hi everyone.

I am having trouble with a javascript menu I have set up on this page. While the other menus (blog, info, links) all work, the archive menu will not display and an error comes up when you load the page. The error says there is a ; missing somewhere but I can't find it. Perhaps another pair of eyes will?... or is something else wrong? Here is the code from the page...

the code...
Code:
<script language="JavaScript">
<!--
// SHOW/HIDE HIDDEN MENUS
/*from The JavaScript Source - http://javascript.internet.com
Original:  Roberto Ortali (ortiz83@libero.it)*/

var Brefer=true;
var Arefer=true;
var Lrefer=true;
var Irefer=true;
function showB() {
	if (Brefer) {
		document.all.boxB.style.visibility="visible";
		Brefer=false;
	} else {
		document.all.boxB.style.visibility="hidden";
		Brefer=true;
	}
}
function showA() {
	if (Arefer) {
		document.all.boxA.style.visibility="visible";
		Arefer=false;
	} else {
		document.all.boxA.style.visibility="hidden";
		Arefer=true;
	}
}
function showL() {
	if (Lrefer) {
		document.all.boxL.style.visibility="visible";
		Lrefer=false;
	} else {
		document.all.boxL.style.visibility="hidden";
		Lrefer=true;
	}
}
function showI() {
	if (Irefer) {
		document.all.boxI.style.visibility="visible";
		Irefer=false;
	} else {
		document.all.boxI.style.visibility="hidden";
		Irefer=true;
	}
}

//-->
</script>
the HTML...
Code:
<tr class="menu"><td>
<a href="#" onClick="showB(); return false;"><img src="blog-on.gif" name="blog" border="0" width="106" height="26" alt="selected posts" /></a><img src="clear.gif" width="10" />
<a href="#" onClick="showA(); return false;"><img src="arch-on.gif" name="arch" border="0" width="106" height="26" alt="links to archives" /></a><img src="clear.gif" width="10" />
<a href="#" onClick="showI(); return false;"><img src="info-on.gif" name="info" border="0" width="106" height="26" alt="about me" /></a><img src="clear.gif" width="10" />
<a href="#" onClick="showL(); return false;"><img src="links-on.gif" name="links" border="0" width="106" height="26" alt="other blogs and websites" /></a>
</td></tr>
I would really appreciate any help! Thank you!
stereohi is offline   Reply With Quote
Old 06-11-2003, 08:24 PM   PM User | #2
stereohi
New Coder

 
Join Date: Jul 2002
Location: Chattanooga, Tennessee
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
stereohi is an unknown quantity at this point
oops, just read the posting guidelines thread, sorry about that!!
stereohi is offline   Reply With Quote
Old 06-11-2003, 09:02 PM   PM User | #3
arnyinc
Regular Coder

 
Join Date: Jan 2003
Posts: 867
Thanks: 4
Thanked 8 Times in 8 Posts
arnyinc is an unknown quantity at this point
Since it only happens with the Archive button, the first thing that comes to mind is to error check that function and it's contents. Try replacing the contents of the div named boxA with some more basic content and see if you still get that error. Embedding that script in there might be the cause of your problem.


<div id="boxA">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="linksA" width="106">test!</td>
</tr>
</table>
</div>

Those 4 functions all do the same thing. You need to reuse your code!
arnyinc is offline   Reply With Quote
Old 06-11-2003, 09:29 PM   PM User | #4
stereohi
New Coder

 
Join Date: Jul 2002
Location: Chattanooga, Tennessee
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
stereohi is an unknown quantity at this point
you're right, it is the embedded code, the test showed up...

It's just strange because it had never not worked before, I haven't altered any code, it just suddenly stopped working...

I've looked over the archive script that I linked to in the box, but I can't find anything missing... but then again I don't know enough about javascript to be able to see much. I just don't understand why it worked before and isn't working now, when I didn't change anything.

This is the archive script...

Code:
// User data
var currentPageName = "current posts";
var currentPageLink = "index.html";
var archivePath = "";
var preLink = "";
var postLink = "";

function ArchivePage_MakeLink(){
  var month_name = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
  var newName = preLink + month_name[this.StartDate.getMonth()]+" "+this.StartDate.getFullYear() + postLink;
  var outString = "";
    
  if ( -1 != location.href.indexOf( this.Link ) ){
    outString = "<span class=\"archivelinks\">" + newName + "</span><br>";
    }
  else{
    outString = "<a href=\"" + archivePath + this.Link + "\" class=\"archivelinks\">" + newName + "</a><br>";
    }
  return outString;
  }

function ArchivePage( theLink, theName  ){
  this.Link = theLink;
  this.Name = theName;
    
  this.StartDate = new Date( this.Name.slice(6,10), this.Name.slice(0,2)-1, this.Name.slice(3,5) );
  this.EndDate = new Date( this.Name.slice(13+6,13+10), this.Name.slice(13+0,13+2)-1, this.Name.slice(13+3,13+5) );
    
  ArchivePage.prototype.MakeLink = ArchivePage_MakeLink;
  }


function FindIdx( myURL ){
  for ( var n=0; n<BlogInfo.length; n++ ){
    if ( -1 != myURL.indexOf( BlogInfo[n].Link ) )
      return n;
    }
  return null;
  }

function WriteArchiveSection( BlogInfo ){

  var start = 0;
  var end = BlogInfo.length;
  var currentPage = FindIdx(location.href);

  if ( null != currentPage ){    document.write( "<a href=\"" + currentPageLink + "\">" + currentPageName + "</a><br>");    }
  for ( var n=start; n<end; n++ ){
    document.write( BlogInfo[n].MakeLink() );
    }

    
  }
var count=0;
var BlogInfo = new Array();
<Blogger>
BlogInfo[count++] = new ArchivePage( "<$BlogArchiveLink$>" , "<$BlogArchiveName$>" );
</Blogger>

WriteArchiveSection( BlogInfo );
stereohi is offline   Reply With Quote
Old 06-12-2003, 04:25 PM   PM User | #5
arnyinc
Regular Coder

 
Join Date: Jan 2003
Posts: 867
Thanks: 4
Thanked 8 Times in 8 Posts
arnyinc is an unknown quantity at this point
I don't see the MakeLink() function defined anywhere in your code. Should the third to last line of this function be ArchivePage_MakeLink()?


function WriteArchiveSection( BlogInfo ){

var start = 0;
var end = BlogInfo.length;
var currentPage = FindIdx(location.href);

if ( null != currentPage ){ document.write( "<a href=\"" + currentPageLink + "\">" + currentPageName + "</a><br>"); }
for ( var n=start; n<end; n++ ){
document.write( BlogInfo[n].MakeLink() );
}
}
arnyinc is offline   Reply With Quote
Old 06-15-2003, 06:38 AM   PM User | #6
stereohi
New Coder

 
Join Date: Jul 2002
Location: Chattanooga, Tennessee
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
stereohi is an unknown quantity at this point
thank you so much for replying! I'm sorry its taken so long for me to respond!

I don't know why MakeLink() is not defined, I didn't write the code (I got it from this guy at this page). But I did try what you suggested, changing this....
Code:
document.write( BlogInfo[n].MakeLink() );
to this
Code:
document.write( BlogInfo[n].ArchivePage_MakeLink() );
but it still didn't work. But MakeLink() still might be the problem... I just wish I knew how to fix it I really appreciate everyone's help!
stereohi is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:39 AM.


Advertisement
Log in to turn off these ads.