Page 1 of 1

problem in including java menu in each page

Posted: Thu Jun 05, 2008 1:01 am
by sonumittal
hi
i m new here....i wanna include menu in my each page....my web structure is
new > main root dir for web having java menu files named head.php( i have used sothink menu generator java script to include menu in this php file, i have inluded java script in the head and body tag of this head.php file as told by the sothnik menu generator)
1 > first folder
2 > 2nd folder
and so on .....
my all web files in php arein main folder.......

i ha
if i include head.php in my php page in main folder using include, it includes ok and works ok ....but suppose my php page in any other folder like in 1 folder here, then inluding head.php
give no menu in the page.....plz tell me how to do it............

Re: problem in including java menu in each page

Posted: Thu Jun 05, 2008 1:30 am
by JAB Creations
You only need to include once, though I've used repetition to show you how you can manipulate directory paths just like adding images (only this is serverside).

Code: Select all

<?php
include("menu.php");
include("../menu.php");
include("../../menu.php");
include("../../main/menu.php");
?>
...and welcome to the forums. :)

Re: problem in including java menu in each page

Posted: Thu Jun 05, 2008 4:41 am
by sonumittal
thnaks ofr your welcome.....


but still it does not include the menu...........
i think the link in the .js file are relative, so they are not included ..........
so i have changed the relative paths to absolute paths....now all the menu is included but there is another problem now.......it is showing the menu but the links in the menu go to other addresses which does not exist.......for example......
i have main.php and head.php containing my main page code and menu respectively in root dir ( root is my main root dir for web)....
main.php > main page data except menu
head.php > menu items...

main.php file look like as

<?php
include "head.php";
-----
----
?>

head.php
<?php
----
<head>< type=css/text javascript .....></head>
<title>aaa</title>
<body>
here is the java code supplied by the sothink menu generator...and in this, i have made the relative addresses absolutee addresses......
</body>

but now i have folder 1 in this main dir....i have profile.php file here which looks like this

<?php
include "../head.php";
-----
some links here....
----
----
?>

whenever i clik on the link in this page, it searches for the file with address "//localhost/1/profile.php" which does not exist.....since the page in the main dir......
and whenever i click in the main page for profile.php, it work fine since it looks for the file //localhost/profile.php

so tell me wat to do.......

tanks in advance.....

Re: problem in including java menu in each page

Posted: Thu Jun 05, 2008 10:01 pm
by JAB Creations
You'll need to clear up your references a lot to communicate more effectively...

1.) Java or JavaScript? I presume JavaScript.

2.) Use [ code ] [ / code ], [ html ] [ / html ], and [ javascript ] [ /javascript ] to encase code to make it easier to read (the BB code will work though don't use the spaces).

3.) If you are trying to include JavaScript that makes your menus work you can create a script element that links to the file...

Code: Select all

<head><script src="my_javascript.js" type="text/javascript"></script></head>
Do not use the langauge attribute (<script language="javascript.....) as it's invalid code.

Take your JavaScript code and simply put it in to the external file.

If you create a standalone single-file test case for posting on forums you can alternatively include your JavaScript code as so...

Code: Select all

<head><script type="text/javascript">//<![CDATA[// Paste JavaScript code here...//]]></script></head>
You can test JavaScript to see if it's included by calling a function. Here is an example...

Code: Select all

<html><head><script type="text/javascript">//<![CDATA[function my_function() {alert('Hello World!');}//]]></script></head> <body> <div><a href="javascript&#058; my_function();">click to test the function</a></div> </body></html>
Keep in mind that JavaScript is clientside and PHP is serverside. I think you may have those mixed up.

Try what I suggested and let me know what progress you've made.

Re: problem in including java menu in each page

Posted: Fri Jun 06, 2008 12:03 am
by sonumittal
my first file is head.php contaiinig javascript........

<html>
<head>
<title>Main</title><script type="text/javascript" src="stmenu.js"></script>
</head>
<body>
<img src="c:/wamp/www/new/images/head.gif" width="800" height="94">
<marquee scrolldelay="95" width="790" height="19"><b>AN ISO-9001, ISO-14001 & OHSAS-18001 UNIT</b></marquee>
<script type="text/javascript">
<!--
stm_bm(["menu0f4d",840,"","blank.gif",0,"","",0,0,0,0,20,1,0,0,"","100",0,0,1,2,"hand","hand",""],this);
stm_bp("p0",[0,4,0,0,0,0,0,0,100,"",-2,"",-2,50,0,0,"#799BD8","transparent","060417line.gif",3,0,0,"#000000","",0,0,0,"transparent","",3,"060417buttona2.gif",26,5,0,"transparent","",3,"",0,0,0,"transparent","",3,"060417buttona1.gif",26,5,0,"transparent","",3,"","","","",0,0,0,0,0,0,0,0]);
stm_ai("p0i0",[0,"Home","","",-1,-1,0,"main.php","_self","","","","",0,0,0,"","",0,0,0,1,1,"#66CC66",1,"#66CC66",1,"round7.gif","round7a.gif",0,0,0,0,"#009900","#009900","#CC3300","#666666","bold 8pt Arial","9pt Segoe Print",0,0],95,26);
stm_aix("p0i1","p0i0",[0,"Company","","",-1,-1,0,""],100,26);
stm_bp("p1",[0,4,-90,0,0,0,0,0,100,"progid:DXImageTransform.Microsoft.Fade(overlap=.5,enabled=0,Duration=0.32)",-2,"progid:DXImageTransform.Microsoft.Fade(overlap=.5,enabled=0,Duration=0.32)",-2,78,0,0,"#799BD8","#EEEEEE","060417line1.gif",3,0,0,"#000000"]);
stm_aix("p1i0","p0i0",[2,"","060417line1b.gif","060417line1b.gif",30,26,0,"","_self","","","","",0,0,0,"","",0,0,0,1,1,"#FFFFF7",1,"#B5BED6",1,"","",3,3,0,0,"#FFFFF7","#000000","#0000FF","#FF6600","bold 7pt Verdana","bold 7pt Verdana"],0,26);
stm_aix("p1i1","p0i0",[0,"Profile","","",-1,-1,0,"company/profile.php"],75,26);
stm_aix("p1i2","p0i0",[0,"Mission","","",-1,-1,0,"company/mission.php"],75,26);
stm_aix("p1i3","p0i1",[0,"Policy"],75,26);
stm_bpx("p2","p1",[0,4,-90,0,0,10]);
stm_aix("p2i0","p0i0",[0,"Quality","","",-1,-1,0,"company/policy/q_policy.php"],75,26);
stm_aix("p2i1","p0i0",[0,"Environmental","","",-1,-1,0,"company/policy/e_policy.php"],75,26);
stm_aix("p2i2","p0i0",[0,"SHE","","",-1,-1,0,"company/policy/s_policy.php"],75,26);
stm_ep();
stm_aix("p1i4","p0i1",[0,"Standards"],75,26);
stm_bpx("p3","p2",[]);
stm_aix("p3i0","p0i0",[0,"ISO-9001","","",-1,-1,0,"company/standards/iso-9001/iso.php"],75,26);
stm_aix("p3i1","p0i0",[0,"ISO-14001","","",-1,-1,0,"company/standards/iso-14001/iso-14001.php"],75,26);
stm_aix("p3i2","p0i0",[0,"OHSAS-18001","","",-1,-1,0,"company/standards/ohsas/ohsas.php"],80,26);
stm_ep();
stm_aix("p1i5","p1i0",[2,"","060417line1a.gif","060417line1a.gif"],0,26);
stm_ep();
stm_aix("p0i2","p0i1",[0,"Plant"],100,26);
stm_bpx("p4","p1",[0,4,-80]);
stm_aix("p4i0","p1i0",[],0,26);
stm_aix("p4i1","p0i0",[0,"Location","","",-1,-1,0,"plant/mapbti.gif"],75,26);
stm_aix("p4i2","p0i0",[0,"Photos","","",-1,-1,0,"plant/photos.php"],75,26);
stm_aix("p4i3","p0i0",[0,"Process","","",-1,-1,0,"plant/process.php"],75,26);
stm_aix("p4i4","p1i5",[],0,26);
stm_ep();
stm_aix("p0i3","p0i1",[0,"Employees"],110,26);
stm_bpx("p5","p1",[0,4,-100]);
stm_aix("p5i0","p1i0",[],0,26);
stm_aix("p5i1","p0i1",[0,"List"],75,26);
stm_bpx("p6","p2",[]);
stm_aix("p6i0","p0i0",[0,"All","","",-1,-1,0,"emp/list.php?id=1"],75,26);
stm_aix("p6i1","p0i0",[0,"Dept Wise","","",-1,-1,0,"emp/list.php?id=2"],75,26);
stm_aix("p6i2","p0i0",[0,"Executive","","",-1,-1,0,"emp/list.php?id=3"],75,26);
stm_aix("p6i3","p0i0",[0,"Non Executive","","",-1,-1,0,"emp/list.php?id=4"],75,26);
stm_ep();
stm_aix("p5i2","p0i0",[0,"Seniority List","","",-1,-1,0,"emp/sen-list.pdf"],110,26);
stm_aix("p5i3","p1i5",[],0,26);
stm_ep();
stm_aix("p0i4","p0i1",[0,"HR"],95,26);
stm_bpx("p7","p4",[]);
stm_aix("p7i0","p1i0",[],0,26);
stm_aix("p7i1","p0i0",[0,"Standing Orders","","",-1,-1,0,"hr/standing.php"],110,26);
stm_aix("p7i2","p0i0",[0,"CDA Rules","","",-1,-1,0,"hr/cda.php"],85,26);
stm_aix("p7i3","p0i0",[0,"Pay Scales","","",-1,-1,0,"hr/payscale.php"],85,26);
stm_aix("p7i4","p0i0",[0,"Forms","","",-1,-1,0,"hr/forms.php"],75,26);
stm_aix("p7i5","p1i5",[],0,26);
stm_ep();
stm_aix("p0i5","p0i1",[0,"Awards"],100,26);
stm_bpx("p8","p1",[0,4,-30]);
stm_aix("p8i0","p1i0",[],0,26);
stm_aix("p8i1","p0i0",[0,"Safety","","",-1,-1,0,"awards/SAFETY.php"],75,26);
stm_aix("p8i2","p0i0",[0,"Others","","",-1,-1,0,"awards/OTHER.php"],75,26);
stm_aix("p8i3","p1i5",[],0,26);
stm_ep();
stm_aix("p0i6","p0i1",[0,"Email"],100,26);
stm_bpx("p9","p2",[0,4,-30]);
stm_aix("p9i0","p0i0",[0,"Corporate Office","","",-1,-1,0,"email/co.php"],65,26);
stm_aix("p9i1","p0i0",[0,"Bathinda","","",-1,-1,0,"email/bti.php"],60,26);
stm_aix("p9i2","p0i0",[0,"Vijaipur","","",-1,-1,0,"email/vjp.php"],60,26);
stm_aix("p9i3","p0i0",[0,"Nangal","","",-1,-1,0,"email/ngl.php"],55,26);
stm_aix("p9i4","p0i0",[0,"Panipat","","",-1,-1,0,"email/pnp.php"],60,26);
stm_aix("p9i5","p0i0",[0,"Chandigarh","","",-1,-1,0,"email/chd.php"],65,26);
stm_aix("p9i6","p0i0",[0,"Lucknow","","",-1,-1,0,"email/lnw.php"],70,26);
stm_aix("p9i7","p0i0",[0,"Bhopal","","",-1,-1,0,"email/bhp.php"],50,26);
stm_ep();
stm_ep();
stm_em();
//-->
</script>
</body>
</html>


my second file main.php is


<html>
<title>NFL</title>
<!Dsession_unset(); ?><br>
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
//-->
</script>
<body>
<table width="960" border="0" cellpadding="0" cellspacing="0" background="images/5.jpg">
<!--DWLayoutTable-->
<tr><th height="21" colspan="2" valign="top">Company And Unit Heads</th>
<td width="17">&nbsp;</td>
<td colspan="3" rowspan="11" valign="top"><p align="center"><strong>WELCOME</strong></p><img src="images/main.gif" height="321" width="428"></td>
<td width="15">&nbsp;
<td colspan="4" align="center" valign="top"><strong>Yesterday's Production</strong>
<tr>
<td width="128" rowspan="6" valign="top" ><br><br><font face="Times New Roman, Times, serif" >&nbsp;&nbsp;Sh <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CMD</font>&nbsp;</td>
<td width="104" rowspan="6" valign="top"><img src="images/cmd.jpg" align="right">&nbsp;</td>
<td height="20">&nbsp;</td>
<td>&nbsp;</td>
<td width="60" valign="top"><strong>Urea</strong></td>
<td colspan="3" valign="top" align="right"><strong>MT</strong></td>
</tr>
<tr>
<td height="20">&nbsp;</td>
<td>&nbsp;</td>
<td colspan="2" valign="top"><strong>Ammonia</strong></td>
<td colspan="2" valign="top" align="right"><strong>MT</strong></td>
</tr>
<tr>
<td height="25">&nbsp;</td>
<td>&nbsp;</td>
<td colspan="4" valign="top" align="center"><strong>Yesterday's Dispatch</strong></td>
</tr>
<tr>
<td height="19">&nbsp;</td>
<td>&nbsp;</td>
<td colspan="3" valign="top"><strong>By Road</strong></td>
<td width="148" align="right" valign="top"><strong>MT</strong></td>
</tr>
<tr>
<td height="20"></td>
<td></td>
<td colspan="3" valign="top"><strong>By Rail</strong></td>
<td align="right" valign="top"><strong>MT</strong></td>
</tr>
<tr>
<td height="13"></td>
<td></td>
<td></td>
<td width="20"></td>
<td width="40"></td>
<td></td>
</tr>
<tr>
<td height="117" valign="top"><br><br><font face="Times New Roman, Times, serif">&nbsp;&nbsp;Sh <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CGM</font>&nbsp;</td>
<td valign="top"><img src="images/cmd.jpg" align="right">&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td colspan="4" rowspan="4" valign="top">
<form name="form1" method="post" action="pers/pers_details.php">
<p align="center"><strong>USER LOGIN</strong></p>
<p align="center">USER NAME
<input name="user" type="text" size="15" maxlength="15">
</p>
<p align="center">PASSWORD
<input name="pass" type="password" size="15" maxlength="15">
</p>
<p align="center">
<input type="submit" name="Submit" value="Submit">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input name="reset" type="reset" id="reset" value="Reset">
</p>
</form></td>
</tr>
<tr><td height="19"></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td height="21" colspan="2" valign="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font face="Segoe UI"><strong>LATEST NOTICE</strong></font><strong>&nbsp;</strong></td>
<td></td>
<td></td>
</tr>
<tr>
<td colspan="2" rowspan="2" valign="top"><h4 align="center"><a href="circular/club.pdf">CLUB NOTICE dated 22-05-08</a></h4>
<h5 align="right"><font face="Arial, Helvetica, sans-serif" size="-1"><a href="circular/prev_notices.php">previous notices</a></font></h5>
</td>
<td height="64"></td>
<td></td>
</tr>
<tr>
<td height="28"></td>
<td width="15"></td>
<td width="400"></td>
<td width="13"></td>
<td></td>
<td colspan="4" valign="top">Plz Give your feedback @ <font color="#FFCCFF"><u><a href="mailto:sonumittal@nfl.co.in"><strong>Sonu
Mittal</strong></a></u></font></td>
</tr>
<tr>
<td height="19">&nbsp;</td>
<td></td>
<td></td>
<td>&nbsp;</td>
<td rowspan="2" valign="top"><img src="images/bday.gif"></td>
<td>&nbsp;</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td height="20" colspan="3" valign="top">DAILY PRODUCTION REPORT</td>
<td></td>
<td></td>
<td></td>
<td colspan="4" rowspan="2" valign="top"><p><a href="press/press.php" target="_self">PRESS RELEASES</a>
<br><a href="download/download.php" target="_self">DOWNLOADS</a>
<br><a href="other_plants.php" target="_self">ABOUT OTHER PLANTS</a>
<br><a href="places.php" target="_self">PLACE TO VISIT</a>
</p>
</td>
</tr>
<tr>
<td height="211" colspan="3" valign="top">SHOW CALENDER HERE</td>
<td>&nbsp;</td>
<td valign="top"><?php include "bday.php" ?>&nbsp;</td>
<td>&nbsp;</td>
<td></td>
</tr>
<tr>
<td height="26">&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td height="20" colspan="11" valign="top" align="center"><a href="sitemap.php" target="_self">Site Map</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="contact.php" target="_self">Contact
us</a></td>
</tr>
<tr>
<td height="15"></td>
<td></td>
<td></td>
<td></td>
<td align="center" valign="top" ><font size="-2">BEST VIEWED IN 1024x768 RESULUTION</font></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td height="16"></td>
<td></td>
<td></td>
<td></td>
<td ></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</table>
</body>
</html>

main javascript file stmenu.js is having code in java


if i include it in main.php..it works fine.
but if i include it in a file with address localhost/new/email/newfile
then it deos not go to the right address.......
wat to do....

Re: problem in including java menu in each page

Posted: Fri Jun 06, 2008 12:46 am
by RobertGonzalez
Use the code tag or I lock this thread. That is entirely too much code to have it shown as code.

Re: problem in including java menu in each page

Posted: Fri Jun 06, 2008 12:54 am
by sonumittal
ok sorry next time i will take care of it......

Re: problem in including java menu in each page

Posted: Fri Jun 06, 2008 1:12 am
by JAB Creations
Yeah put your code in to BB code as I described in the above post in this thread please.

[ html ] *HTML code here [ / html ]

With OUT the spaces within the BB code brackets. I recommend editing your existing thread, applying the BB code, and use the PREVIEW button to see if you got it to work correctly.

Any way JavaScript should not be placed within the body <body></body> element. If it doesn't work when linked as a file in a script element it's simply not well written.

Actually that JavaScript looks strikingly familiar to a menu I used years and years ago. Any way take all of the JavaScript code and put it in to a file. Name it something like menu.js. Then between your head element <head></head> add the following line...

Code: Select all

<script src="menu.js" type="text/javascript"></script>
As far as includes go I don't think you're comprehending serverside versus clientside. When you include files together you're essentially taking puzzle pieces and sticking them together.

Take these three files and run them on your local server. They should work fine as-is because I know you're likely to just copy and paste. When you open the file in your browser you'll notice that there aren't multiple body elements.

You really need to validate your clientside output which is the HTML you are generating. My example below will validate (except for the media type/mime but don't even inquire about that at this point). Any way this should get you going in the right direction I hope...

header.html

Code: Select all

<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"><head><title>Example</title><script src="menu.js" type="text/javascript"></script></head>
footer.html

Code: Select all

<body> <div><p>Your content here.</p></div> </body></html>
main.php

Code: Select all

<?php
include("header.html");
include("footer.html");
?>

Re: problem in including java menu in each page

Posted: Fri Jun 06, 2008 1:38 am
by sonumittal
i ahve 6 .js files ...........you mean to say include all 6 fiels code in a single file....
and tehn inlcude it ...

Re: problem in including java menu in each page

Posted: Fri Jun 06, 2008 1:50 am
by RobertGonzalez
Let's get the lingo straight really quick. You are not including javascript files, you are referencing them in your markup.

You can make three, four, 20... whatever number of includes you want, but the calls to the javasript references should be in your markup, in the head section, between <script></script> tags, one for each .JS file you plan on referencing.

Re: problem in including java menu in each page

Posted: Fri Jun 06, 2008 1:55 am
by JAB Creations
Read everything we've posted, the answers are all already here. It's up to you to decide to learn the references, connect the dots, and try out what we're suggesting.