You are here:

DHTML/Javascript Question...

Advertisement


Question
Got from www.dymanimdrive.com. My web address is http:/hwc.ccc.edu/creativeaging. Address of my Javascript file is http://hwc.ccc.edu/creativeaging/menuItems2.js Got the script from here http://www.dynamicdrive.com/dynamicindex1/popit.htm Tried to add "Spring 2009 Lecture Series" as a link, but not taking for some unexplained reason.

Answer
Hi Dennis,

You're missing a '+' sign.  Here's what you have:

linkset[1]='<a href="lectureseries.htm">Spring 2009 Lecture Series</a>'
linkset[1]+='<hr>' //Optional Separator
linkset[1]='<a href="main.htm">Spring 2008 Lecture Series</a>'
linkset[1]+='<hr>' //Optional Separator
linkset[1]+='<a href="lecture.htm">Spring 2007 Lecture Series</a>'

Here's what you need:

linkset[1]='<a href="lectureseries.htm">Spring 2009 Lecture Series</a>'
linkset[1]+='<hr>' //Optional Separator
linkset[1]+='<a href="main.htm">Spring 2008 Lecture Series</a>'
linkset[1]+='<hr>' //Optional Separator
linkset[1]+='<a href="lecture.htm">Spring 2007 Lecture Series</a>'

In the first block, you're seeing the first item to Spring 2009 Lecture Series--which is what you wanted.  But then, on the third line, you're resetting teh linkset[1] array by using '=' without the '+'.  The plus sign says, 'take what we have so far and add this to it.'  The equals sign says, 'I don't care what we may have had.  Now all we have is this.'  

DHTML

All Answers


Answers by Expert:


Ask Experts

Volunteer


Andrew Hoffman

Expertise

Ask me about JavaScript, CSS, HTML5/XHTML, or PHP. Chances are I'll be able to help you. I know the economy is in the tank, but if you like my answer, please consider donating a few bucks. It's like tipping your barista, if your barista served fresh code instead of coffee.

Experience

I started doing this when boy bands were still cool.

Education/Credentials
I read a lot of nerdy books to get here.

©2012 About.com, a part of The New York Times Company. All rights reserved.