473,408 Members | 1,700 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

I am new and having a problem on something I believe should be simple

Hi All,

I am trying to assist my wife, by making a simple menu system for the website.

The web page is a .php4 file and does an include of the navigation file. Before it includes that file at the top I have the following line of code to include my .js file.

<script src="scripts/SideNav.js" language="JavaScript" type="text/javascript"></script>

that is inside the <head> tag. It used to work fine with a more hard coded version of the menu system. I am trying to generalize it a little bit.

The .js file looks like the following.

var MenuObject = new Array();
MenuObject[ 0 ] = "NoChoices";
MenuObject[ 1 ] = "Location01";
MenuObject[ 2 ] = "BookChoices";
MenuObject[ 3 ] = "NewsChoices";
MenuObject[ 4 ] = "PeekInsideChoices";
MenuObject[ 5 ] = "ReadReviewsChoices";
MenuObject[ 6 ] = "AuthorChoices";
MenuObject[ 7 ] = "ConsultingChoices";
MenuObject[ 8 ] = "ResourcesChoices";


function DoNothing()
{
}


function CancelEvent()
{
event.cancelBubble=true;
event.returnValue=false;
}


function PageEnter( menuobj, menustring )
{
CloseAllChoices( menuobj, menustring );
}


function LocateChoiceIndex( menuobj, menustring )
{
var RetVal = null; // Currently an ILLEGAL index value.

// Go through looking for the correct index value.
for( var IdxVal=0; (IdxVal < menuobj.length); IdxVal++ )
{
// See if the string at the Index Value Matches what we are looking for.
if ( menustring == menuobj[IdxVal] )
{
RetVal = IdxVal; // If we found the IndexValue then Great.
break;
}
}

return ( RetVal );
}


function ShowGroup( menuobj, menuname )
{
CloseAllChoices( menuobj, menuname );
OpenChoice( menuname );
}

function OpenChoice( groupname )
{
document.getElementById( groupname ).className = "NavChoicesShow";
}


function CloseChoice( groupname )
{
document.getElementById( groupname ).className = "NavChoicesHide";
}


function CloseAllChoices( menuobj, menustring )
{
var StartingChoiceIdx = LocateChoiceIndex( menuobj, menustring );
var IdxVal = 0; // Use this as a loop Counter to go through all the menu choices.

var MenuNameStr = menuobj[0];
CloseChoice( MenuNameStr ); // Use the Proper Name String.

// Code never gets here, because it doesn't seem to return from CloseChoice() call above.
// I have tried it with a return and without.
alert( MenuNameStr );
MenuNameStr = menuobj[1];
CloseChoice( MenuNameStr ); // Use the Proper Name String.
MenuNameStr = menuobj[2];
CloseChoice( MenuNameStr ); // Use the Proper Name String.
MenuNameStr = menuobj[3];
CloseChoice( MenuNameStr ); // Use the Proper Name String.
MenuNameStr = menuobj[4];
CloseChoice( MenuNameStr ); // Use the Proper Name String.
MenuNameStr = menuobj[5];
CloseChoice( MenuNameStr ); // Use the Proper Name String.
MenuNameStr = menuobj[6];
CloseChoice( MenuNameStr ); // Use the Proper Name String.
MenuNameStr = menuobj[7];
CloseChoice( MenuNameStr ); // Use the Proper Name String.
MenuNameStr = menuobj[8];
CloseChoice( MenuNameStr ); // Use the Proper Name String.
alert( MenuNameStr );


// Ensure we have a Valid Index Value.
if ( StartingChoiceIdx != null )
{
/*
** Go Through All of the MenuChoices turning off the ones We don't currently have open.
*/
alert( 'Valid index.' );
for( IdxVal=StartingChoiceIdx+1; (IdxVal < menuobj.length); IdxVal++ )
{
// Close the Current Menu Choice.
CloseChoice( menuobj[IdxVal] ); // Use the Proper Name String.
}
}
else
{
alert( 'Can\'t find a valid index.' );
/*
** Here if the Index Value was ILLEGAL.
** Therefore Close ALL choices.
*/

// Go through Closing ALL menu Choices.
for( IdxVal=0; (IdxVal < menuobj.length); IdxVal++ )
{
// Close this Specific Menu Choice.
CloseChoice( menuobj[IdxVal] ); // Use the Proper Name String.
}
}
}


Then in the navigation file that gets included, I have sections that look like the following.

<span id="Location01" name="Location01" class="NavChoicesShow"
onMouseOver="ShowGroup( MenuObject, MenuObject[1] );" onMouseOut="CancelEvent();" >
&nbsp;
</span>


<a name="Book" href="/index.php4" class="SideNav"
onMouseOver="ShowGroup( MenuObject, MenuObject[2] );" onMouseOut="CancelEvent();">The Book</a>
<br />
<span id="BookChoices" name="BookChoices" class="NavChoicesShow" >
<a name="BuyItNow" href="/buyitnow.php4" class="NavChoices"
onMouseOver="ShowGroup( MenuObject, MenuObject[2]);" onMouseOut="CancelEvent();" >- Bookstore Links</a>
<br />
</span>
<img src="/includes/whiteline2.gif" width="112" height="14"><br />


<a name="News" href="/press/index.php4" class="SideNav"
onMouseOver="ShowGroup( MenuObject, MenuObject[3] );" onMouseOut="CancelEvent();">News &amp; Press</a>
<br />
<span id="NewsChoices" name="NewsChoices" class="NavChoicesShow" >
</span>
<img src="/includes/whiteline2.gif" width="112" height="14"><br />


<a name="PeekInside" href="/sneakpeek/index.php4" class="SideNav"
onMouseOver="ShowGroup( MenuObject, MenuObject[4] );" onMouseOut="CancelEvent();">Peek Inside</a>
<br />
<span id="PeekInsideChoices" name="PeekInsideChoices" class="NavChoicesShow" >
<a name="TOC" href="../sneakpeek/index.php4" class="NavChoices"
onMouseOver="ShowGroup( MenuObject, MenuObject[4] );" onMouseOut="CancelEvent();" >- Table of Contents</a>
<br />
<a name="Excerpts" href="../sneakpeek/excerpts.php4" class="NavChoices"
onMouseOver="ShowGroup( MenuObject, MenuObject[4] );" onMouseOut="CancelEvent();" >- Excerpts</a>
<br />
<a name="Book Cover" href="../sneakpeek/backcover.php4" class="NavChoices"
onMouseOver="ShowGroup( MenuObject, MenuObject[4] );" onMouseOut="CancelEvent();" >- Back Cover</a>
<br />
</span>
<img src="/includes/whiteline2.gif" width="112" height="14"><br />


<a name="ReadReviews" href="/reviews/index.php4" class="SideNav"
onMouseOver="ShowGroup( MenuObject, MenuObject[5] );" onMouseOut="CancelEvent();">Reviews</a>
<br />
<span id="ReadReviewsChoices" name="ReadReviewsChoices" class="NavChoicesShow" >
</span>
<img src="/includes/whiteline2.gif" width="112" height="14"><br />


<a name="Author" href="/theauthor/index.php4" class="SideNav"
onMouseOver="ShowGroup( MenuObject, MenuObject[6] );" onMouseOut="CancelEvent();">The Author</a>
<br />
<span id="AuthorChoices" name="AuthorChoices" class="NavChoicesShow" >
</span>
<img src="/includes/whiteline2.gif" width="112" height="14"><br />


<a name="Consulting" href="/consultingservices.php4" class="SideNav"
onMouseOver="ShowGroup( MenuObject, MenuObject[7] );" onMouseOut="CancelEvent();">Consulting Services</a>
<br />
<span id="ConsultingChoices" name="ConsultingChoices" class="NavChoicesShow" >
</span>
<img src="/includes/whiteline2.gif" width="112" height="14"><br />


<a name="Resources" href="/resources/index2.php4" class="SideNav"
onMouseOver="ShowGroup( MenuObject, MenuObject[8] );" onMouseOut="CancelEvent();">Free Resources</a>
<br />
<span id="ResourcesChoices" name="ResourcesChoices" class="NavChoicesShow" >
<a name="DiscussionGroup" href="../MessageBoard/index.php4" class="NavChoices"
onMouseOver="ShowGroup( MenuObject, MenuObject[8] );" onMouseOut="CancelEvent();" >- Discussion Group</a>
<br />
<a name="Articles" href="../resources/article_1.php4" class="NavChoices"
onMouseOver="ShowGroup( MenuObject, MenuObject[8] );" onMouseOut="CancelEvent();" >- Articles</a>
<br />
<a name="AskTheAuthor" href="../resources/index.php4" class="NavChoices"
onMouseOver="ShowGroup( MenuObject, MenuObject[8] );" onMouseOut="CancelEvent();" >- Ask the Author</a>
<br />
<a name="Links" href="../resources/toolslinks.php4" class="NavChoices"
onMouseOver="ShowGroup( MenuObject, MenuObject[8] );" onMouseOut="CancelEvent();" >- Links</a>
<br />
<a name="Bookstore" href="../resources/bookpicks.php4" class="NavChoices"
onMouseOver="ShowGroup( MenuObject, MenuObject[8] );" onMouseOut="CancelEvent();" >- Bookstore</a>
<br />
<a name="CoolStuff" href="../resources/getequipped.php4" class="NavChoices"
onMouseOver="ShowGroup( MenuObject, MenuObject[8] );" onMouseOut="CancelEvent();" >- Cool Stuff!</a>
<br />
<a name="Charity" href="../CharityInfo/CharityPage.php4" class="NavChoices"
onMouseOver="ShowGroup( MenuObject, MenuObject[8] );" onMouseOut="CancelEvent();" >- Charity Info</a>
<br />
</span>
<img src="/includes/whiteline2.gif" width="112" height="14"><br />


However, the darn thing doesn't work.

I have placed a few "alert()" calls to see where the code is getting, and try to see where my problem is. It looks like once inside the "CloseAllChoices()" function if I move the alert() above the first " CloseChoice( MenuNameStr );" call that I can see the alert and then things end. However, when the alert() comes after that call, I never even see the Alert Dialog box. I have no idea why this code just seems to stop and never come back. In addition I have tried adding "return()" to the functions to see if that was causing it for some reason, but to no avail.

Please help. I think this should be an easy one for someone who knows Javascript, but I just don't have any real exposure to the language.

Also, I use a Mac, is there anything I can use to actually try to debug this stuff?

Sincerely,
Kevin Shapiro
Sep 7 '06 #1
1 1421
Banfa
9,065 Expert Mod 8TB
I can't see anything obvious wrong.

Make sure that you use a decent browser (and by this a mean NOT IE), I am not sure what is available for the Mac but is available Firefox, Mozilla, Netscape or Opera are good choices.

Make sure you have found in the browser you are using the methods of debuging you javascript, for instance IE has a yellow error triangle that appears on the status bar that you double click to get the error. Firefox has a Javascript console that lists all error sthat have occured.

If you can post a link to the page here so that we can take a look for ourselves.
Sep 8 '06 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: SB | last post by:
Ok, very simple problem. I'm trying to update a value by calling a function using pass by reference, but it does not update the value. In short, the value I'm trying to update is balance, which is...
3
by: Tyrone Slothrop | last post by:
The first question, is this even possible? What I need to do is pass the contents of a PHP web page from a textarea using window.open method to a new browser window and display it. The page has...
17
by: Jon Slaughter | last post by:
I'm having a little trouble understanding what the slicing problem is. In B.S.'s C++ PL3rdEd he says "Becayse the Employee copy functions do not know anything about Managers, only the Employee...
5
by: Carmine Cairo | last post by:
Hi, I'm working on a project and today I've note a little problem during the compile fase. Here a little piece of code: // 1st version welldone = 0; size = p->getSize(); backbone = new...
2
by: Steve Bottoms | last post by:
Hi, all! Using VB as code-behind in asp.net page... I have a TABLE control which I'm building dynamically. After the table is built, I'm trying to retrieve the HEIGHT property of that table...
16
by: Dany | last post by:
Our web service was working fine until we installed .net Framework 1.1 service pack 1. Uninstalling SP1 is not an option because our largest customer says service packs marked as "critical" by...
6
by: TPJ | last post by:
Help me please, because I really don't get it. I think it's some stupid mistake I make, but I just can't find it. I have been thinking about it for three days so far and I still haven't found any...
5
by: Josh Nikle | last post by:
I have a webform containing a GridView control "GridView1" and usercontrol which is also a GridView "GridView2." I have a button column in the usercontrol. The code behind that button adds an...
28
by: jmDesktop | last post by:
Studying OOP and noticed that Python does not have Interfaces. Is that correct? Is my schooling for nought on these OOP concepts if I use Python. Am I losing something if I don't use the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.