PHP / JQuery induced headache.
Ok so I'm starting to go insane. I cannot for the life of me figure out why I can make text in my navBar fadeIn and fadeOut with jQuery no problem on my HTML document but the second I try and use the .js file on my .php the .hover() does not work.
Anyways, I'm not sure if anyone here is great at JQuery and PHP but I've spent hours trying to figure out what I'm doing wrong and I could really use another couple pairs of eyes...
HTML File:
[code]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- TemplateBeginEditable name="doctitle" -->
<title>Page Title</title>
<!-- TemplateEndEditable -->
<!-- TemplateBeginEditable name="head" -->
<!-- TemplateEndEditable -->
<style type="text/css">
<!--
body {
font: 100% Verdana, Arial, Helvetica, sans-serif;
margin: 0; /* it's good practice to zero the margin and padding of the body element to account for differing browser defaults */
padding: 0;
text-align: center; /* this centers the container in IE 5* browsers. The text is then set to the left aligned default in the #container selector */
color: #000000;
background-color: #FFF;
background-image: url(background.gif);
background-repeat: repeat-x;
}
.twoColHybLtHdr #container {
width: 80%;
margin: 0 auto; /* the auto margins (in conjunction with a width) center the page */
border: 1px solid #000000;
text-align: left;
}
.twoColHybLtHdr #sidebar1 {
float: left;
width: 12em; /* top and bottom padding create visual space within this div */
background-color: #CCC;
padding-top: 15px;
padding-right: 0;
padding-bottom: 15px;
padding-left: 0;
background-image: url(ThseeNavBar2.gif);
background-repeat: repeat-x;
}
.twoColHybLtHdr #sidebar1 h3, /*.twoColHybLtHdr*/ #sidebar1 p {
margin-left: 10px; /* the left and right margin should be given to every element that will be placed in the side columns */
margin-right: 10px;
}
...styles...
</style>
<script type="text/javascript" src="js/jquery-1.4.1.js"></script>
<script type="text/javascript" src="js/custom.js"></script>
<![endif]--></head>
<body bgcolor="#33CC66" class="twoColHybLtHdr">
<div id="container">
<div id="header">
<h1 align="right"><a href="login.php"><font size="1">Login</font></a></h1>
<h1 align="center"><img src="ThseeBanner2.gif" width="800" height="100" /></h1>
<!-- end #header --></div>
<div id="sidebar1">
<p><a href="index.htm">Home</a></p>
<p><a href="our_products.htm">Our Products</a></p>
<p><a href="store_location.htm">Store Location</a></p>
<p><a href="contact_us.htm">Contact Us</a></p>
<!-- end #sidebar1 --></div>
<div id="mainContent">
<!--...content...-->
<!-- end #mainContent --></div>
<!-- This clearing element should immediately follow the #mainContent div in order to force the #container div to contain all child floats -->
<br class="clearfloat" />
<div id="footer">
<p align="center"> </p>
<!-- end #footer --></div>
<!-- end #container --></div>
</body>
</html>[/code]
PHP file (the one that refuses to accept js hover(), fadeIn() and fadeOut().):
[code]<?php
session_start(); // start the session
if(!isset($_SESSION['user'])){
// check if the user is logged in
// the user is not logged in
header("Location: login.php"); // take him/her to the login page
} else { ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- TemplateBeginEditable name="doctitle" -->
<title>PageTitle</title>
<!-- TemplateEndEditable -->
<!-- TemplateBeginEditable name="head" -->
<!-- TemplateEndEditable -->
<style type="text/css">
body {
font: 100% Verdana, Arial, Helvetica, sans-serif;
margin: 0; /* it's good practice to zero the margin and padding of the body element to account for differing browser defaults */
padding: 0;
text-align: left; /* this centers the container in IE 5* browsers. The text is then set to the left aligned default in the #container selector */
color: #000000;
background-color: #FFF;
background-image: url(background.gif);
background-repeat: repeat-x;
}
.twoColHybLtHdr #container {
width: 80%;
margin: 0 auto; /* the auto margins (in conjunction with a width) center the page */
border: 1px solid #000000;
text-align: left; /* this overrides the text-align: center on the body element. */
background-color: #6C6;
}
.twoColHybLtHdr #sidebar1 {
float: left;
width: 12em; the background color will be displayed for the length of the content in the column, but no further
padding: 15px 0; top and bottom padding create visual space within this div
background-color: #FFF;
background-image: url(ThseeNavBar2.gif);
background-repeat: repeat-x;
}
.twoColHybLtHdr #sidebar1 h3, /*.twoColHybLtHdr*/ #sidebar1 p {
margin-left: 10px;
margin-right: 10px;
cursor:pointer;
}
<!--more styles...-->
</style>
<script type="text/javascript" src="js/jquery-1.4.1.js"></script>
<script type="text/javascript" src="js/custom.js"></script>>
<!--[if IE]>
<style type="text/css">
/* place css fixes for all versions of IE in this conditional comment */
.twoColHybLtHdr #sidebar1 { padding-top: 30px; }
.twoColHybLtHdr #mainContent { zoom: 1; padding-top: 15px; }
/* the above proprietary zoom property gives IE the hasLayout it may need to avoid several bugs */
</style>
<![endif]--></head>
<body class="twoColHybLtHdr">
<div id="container">
<div id="header">
<h1 align="right"><font size="1"><a href="process_logout.php">Log Out</a></font></h1>
<h1 align="center"><img src="zthseemban.gif" width="800" height="100" /></h1>
<!-- end #header --></div>
<!--this is the EXACT same sidebar as the HTML file.. WHY IS IT NOT WORKING?!-->
<div id="sidebar1">
<p><a href="protected.php">Home</a></p>
<p><a href="z_viewProfile.php">View Profile</a></p>
<p><a href="z_viewcart.php">View Cart</a></p>
<p><a href="z_checkout.php">Checkout</a></p>
<p><a href="process_logout.php">Log Out</a></p>
<!--end #sidebar1 --></div>
<div id="mainContent">
<!--main Content-->
<!-- end #mainContent --></div>
<!-- This clearing element should immediately follow the #mainContent div in order to force the #container div to contain all child floats -->
<br class="clearfloat" />
<div id="footer">
<p> </p>
<!-- end #footer --></div>
<!-- end #container --></div>
</body>
</html>
<?}[/code]
?>
and here is custom.js. It is supposed to fade the text of the navBar when I mouse over:
[code]$(document).ready(function(){
alert('test');
$('#sidebar1 p').fadeTo("fast", 1.0); // This sets the opacity of the thumbs to fade down to 60% when the page loads
$('#sidebar1 p').hover(function(){
alert('hello thar Im the sideBar');
$(this).fadeTo("slow", 0.3); // This should set the opacity to 100% on hover
},function(){
$(this).fadeTo("slow", 1.0); // This should set the opacity back to 60% on mouseout
});
});[/code]
The .js file works perfectly well for the HTML file but when I try and insert the script into the PHP file all I get is the first alert. Clearly something is different between .htm and .php files that I have not accounted for and can find LITERALLY NOWHERE on the internet.
I will be so happy if someone can help me out. I've been wracking my brain for hours on this and you would be my personal jesus:P.