473,569 Members | 2,542 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

1 New Member
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="JavaS cript" 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 ] = "BookChoice s";
MenuObject[ 3 ] = "NewsChoice s";
MenuObject[ 4 ] = "PeekInsideChoi ces";
MenuObject[ 5 ] = "ReadReviewsCho ices";
MenuObject[ 6 ] = "AuthorChoices" ;
MenuObject[ 7 ] = "ConsultingChoi ces";
MenuObject[ 8 ] = "ResourcesChoic es";


function DoNothing()
{
}


function CancelEvent()
{
event.cancelBub ble=true;
event.returnVal ue=false;
}


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


function LocateChoiceInd ex( 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.getEle mentById( groupname ).className = "NavChoicesShow ";
}


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


function CloseAllChoices ( menuobj, menustring )
{
var StartingChoiceI dx = LocateChoiceInd ex( 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 ( StartingChoiceI dx != null )
{
/*
** Go Through All of the MenuChoices turning off the ones We don't currently have open.
*/
alert( 'Valid index.' );
for( IdxVal=Starting ChoiceIdx+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="Location0 1" class="NavChoic esShow"
onMouseOver="Sh owGroup( MenuObject, MenuObject[1] );" onMouseOut="Can celEvent();" >
&nbsp;
</span>


<a name="Book" href="/index.php4" class="SideNav"
onMouseOver="Sh owGroup( MenuObject, MenuObject[2] );" onMouseOut="Can celEvent();">Th e Book</a>
<br />
<span id="BookChoices " name="BookChoic es" class="NavChoic esShow" >
<a name="BuyItNow" href="/buyitnow.php4" class="NavChoic es"
onMouseOver="Sh owGroup( MenuObject, MenuObject[2]);" onMouseOut="Can celEvent();" >- 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="Sh owGroup( MenuObject, MenuObject[3] );" onMouseOut="Can celEvent();">Ne ws &amp; Press</a>
<br />
<span id="NewsChoices " name="NewsChoic es" class="NavChoic esShow" >
</span>
<img src="/includes/whiteline2.gif" width="112" height="14"><br />


<a name="PeekInsid e" href="/sneakpeek/index.php4" class="SideNav"
onMouseOver="Sh owGroup( MenuObject, MenuObject[4] );" onMouseOut="Can celEvent();">Pe ek Inside</a>
<br />
<span id="PeekInsideC hoices" name="PeekInsid eChoices" class="NavChoic esShow" >
<a name="TOC" href="../sneakpeek/index.php4" class="NavChoic es"
onMouseOver="Sh owGroup( MenuObject, MenuObject[4] );" onMouseOut="Can celEvent();" >- Table of Contents</a>
<br />
<a name="Excerpts" href="../sneakpeek/excerpts.php4" class="NavChoic es"
onMouseOver="Sh owGroup( MenuObject, MenuObject[4] );" onMouseOut="Can celEvent();" >- Excerpts</a>
<br />
<a name="Book Cover" href="../sneakpeek/backcover.php4" class="NavChoic es"
onMouseOver="Sh owGroup( MenuObject, MenuObject[4] );" onMouseOut="Can celEvent();" >- Back Cover</a>
<br />
</span>
<img src="/includes/whiteline2.gif" width="112" height="14"><br />


<a name="ReadRevie ws" href="/reviews/index.php4" class="SideNav"
onMouseOver="Sh owGroup( MenuObject, MenuObject[5] );" onMouseOut="Can celEvent();">Re views</a>
<br />
<span id="ReadReviews Choices" name="ReadRevie wsChoices" class="NavChoic esShow" >
</span>
<img src="/includes/whiteline2.gif" width="112" height="14"><br />


<a name="Author" href="/theauthor/index.php4" class="SideNav"
onMouseOver="Sh owGroup( MenuObject, MenuObject[6] );" onMouseOut="Can celEvent();">Th e Author</a>
<br />
<span id="AuthorChoic es" name="AuthorCho ices" class="NavChoic esShow" >
</span>
<img src="/includes/whiteline2.gif" width="112" height="14"><br />


<a name="Consultin g" href="/consultingservi ces.php4" class="SideNav"
onMouseOver="Sh owGroup( MenuObject, MenuObject[7] );" onMouseOut="Can celEvent();">Co nsulting Services</a>
<br />
<span id="ConsultingC hoices" name="Consultin gChoices" class="NavChoic esShow" >
</span>
<img src="/includes/whiteline2.gif" width="112" height="14"><br />


<a name="Resources " href="/resources/index2.php4" class="SideNav"
onMouseOver="Sh owGroup( MenuObject, MenuObject[8] );" onMouseOut="Can celEvent();">Fr ee Resources</a>
<br />
<span id="ResourcesCh oices" name="Resources Choices" class="NavChoic esShow" >
<a name="Discussio nGroup" href="../MessageBoard/index.php4" class="NavChoic es"
onMouseOver="Sh owGroup( MenuObject, MenuObject[8] );" onMouseOut="Can celEvent();" >- Discussion Group</a>
<br />
<a name="Articles" href="../resources/article_1.php4" class="NavChoic es"
onMouseOver="Sh owGroup( MenuObject, MenuObject[8] );" onMouseOut="Can celEvent();" >- Articles</a>
<br />
<a name="AskTheAut hor" href="../resources/index.php4" class="NavChoic es"
onMouseOver="Sh owGroup( MenuObject, MenuObject[8] );" onMouseOut="Can celEvent();" >- Ask the Author</a>
<br />
<a name="Links" href="../resources/toolslinks.php4 " class="NavChoic es"
onMouseOver="Sh owGroup( MenuObject, MenuObject[8] );" onMouseOut="Can celEvent();" >- Links</a>
<br />
<a name="Bookstore " href="../resources/bookpicks.php4" class="NavChoic es"
onMouseOver="Sh owGroup( MenuObject, MenuObject[8] );" onMouseOut="Can celEvent();" >- Bookstore</a>
<br />
<a name="CoolStuff " href="../resources/getequipped.php 4" class="NavChoic es"
onMouseOver="Sh owGroup( MenuObject, MenuObject[8] );" onMouseOut="Can celEvent();" >- Cool Stuff!</a>
<br />
<a name="Charity" href="../CharityInfo/CharityPage.php 4" class="NavChoic es"
onMouseOver="Sh owGroup( MenuObject, MenuObject[8] );" onMouseOut="Can celEvent();" >- 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 "CloseAllChoice s()" 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 1432
Banfa
9,065 Recognized Expert Moderator Expert
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
1720
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 a private member of the class Account. I have a public function called getBalance(). I have another public function called deposit, which I pass the...
3
1681
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 a combination of HTML and PHP. The problem is that the PHP is not being interpreted. This is generally resolved by using the PHP eval() function....
17
16086
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 part of Manager is copied. ".... and gives the code above as .....
5
3311
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 rightType;
2
2715
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 (table.height.value) to be able to dynamically position the next elements on the form. However, this control property is coming back as -0- every...
16
4882
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 Microsoft must be installed on their servers. Now german Umlaute (ä, ü, ö) and quotes are returned incorrectly in SOAP fault responses. This can be...
6
2333
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 solution. My code can be downloaded from here: http://www.tprimke.net/konto/PyObject-problem.tar.bz2. There are some scripts for GNU/Linux system...
5
2336
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 entry to my database, which it's doing fine, but I can't get GridView1 to show the updated data unless I browse to another page and then come back. ...
28
1654
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 "typical" oop constructs found in other languages (Java, C# come to mind.) I'm afraid that if I never use them I'll lose them and when I need them for...
0
7700
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7614
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7924
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8125
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
6284
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5219
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3653
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2114
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1221
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.