Forum Moderators: open

Message Too Old, No Replies

links get changed in included menu

         

andre73

12:14 am on Dec 6, 2004 (gmt 0)

10+ Year Member



hi I'm new to asp and I have a problem/question. I have a menu which is called menu.htm and it is included in my index.asp file. On the index.asp page all the links work fine. However, after i click the link that leads to tablesDine.asp, which also has the menu.htm included, all of the links now have been changed instead of displaying for example, /tablesDine/index.asp they have all gotten the directory tablesDine added to them so the example I just gave looks like this /tablesDine/tablesDine/index.asp. Can anyone help me with this? The code for the menu is below.

<script language="JavaScript1.2">
function hideshow(which){
if (!document.getElementById)
return
if (which.style.display=="none")
which.style.display=""
else
which.style.display="none"
}
function hide(which){
if (!document.getElementById)
return
if (which.style.display=="")
which.style.display="none"
}
</script>
<div id="otherSub" style="display:none;">
<a href="#">Lampor</a>
<a href="#">Hyllor</a>
<a href="#">Prydnad</a>
<a href="#">Rotting</a>
<a href="#">Utem&ouml;bler</a>
</div>

<div id="sortimentSub" style="display:none;">
<a href="tablesDine/tablesDine.asp" id="matbord">MATBORD</a>
<a href="#" id="soffor" onClick="javascript:hide(document.getElementById('otherSub'))">SOFFOR</a>
<a href="#" id="soffbord" onClick="javascript:hide(document.getElementById('otherSub'))">SOFFBORD</a>
<a href="#" id="skap" onClick="javascript:hide(document.getElementById('otherSub'))">SKÅP</a>
<a href="#" id="sangar" onClick="javascript:hide(document.getElementById('otherSub'))">SÄNGAR </a>
<a href="#" id="smide" onClick="javascript:hide(document.getElementById('otherSub'))">SMIDE</a>
<a href="#" id="konst" onClick="javascript:hide(document.getElementById('otherSub'))">KONST</a>
<a href="#" id="ovrigt" onClick="javascript:hideshow(document.getElementById('otherSub'))">ÖVRIGT</a>
</div>

<div id="mainMenu">
<a href="#" id="sortiment" onClick="javascript:hideshow(document.getElementById('sortimentSub'))">SORTIMENT</a>
<a href="#" id="butiken" onClick="javascript:hide(document.getElementById('sortimentSub'))">BUTIKEN</a>
<a href="#" id="leverantorer" onClick="javascript:hide(document.getElementById('sortimentSub'))">LEVERANT&Ouml;RER</a>
<a href="#" id="kontakta" onClick="javascript:hide(document.getElementById('sortimentSub'))">KONTAKTA OSS</a>
<a href="#" id="startsidas" onClick="javascript:hide(document.getElementById('sortimentSub'))">STARTSIDA</a>
</div>

webboy1

4:30 pm on Dec 6, 2004 (gmt 0)

10+ Year Member



It looks like the problem may be to do with your directory structure i.e. how your folders and files are laid out.

For instance, if file1.asp is in the root of your directory and file2.asp is within a folder within the directory, then the include will not work in both.

You have used the include in index.asp which is your main homepage i assume. The includes will work fine and will link to, for example, /tablesDine/index.asp without any problems.

However, when you are in tablesDine/index.asp your include won't work. It is looking for the directory 'tablesdine' within the tablesdine folder - which doesn't exist....... does this make sense?

An easy way around this is to have 2 versions of your include file. The first for all root files i.e. your homepage, and the second for all files located within sub-directories.

You will have to make sure the 2nd include has the correct paths to the relevant files. This could be as simple as adding a ../ in front of the current path name.

Hope this helps!

andre73

5:07 pm on Dec 6, 2004 (gmt 0)

10+ Year Member



thanks for the help!

webboy1

9:25 am on Dec 7, 2004 (gmt 0)

10+ Year Member



No problems ...... did it work?

andre73

9:33 am on Dec 7, 2004 (gmt 0)

10+ Year Member



I moved the file I linked to up to the same directory as the index.asp file then it worked. I did this before I received your answer so I haven't tried your solution, it does make sense though.