Solved

php include of javascript file (in php) works, but javascript include does not show javascript effects

Posted on 2013-06-03
3
540 Views
Last Modified: 2013-06-03
<?php include 'js/members.php'; ?>

<script src='js/members.js';
i do same file as .js
I can see the file in firebug

but none of js features are implemented

  <script type='text/javascript'>
  
  // Browser safe opacity handling function
  
  // membership requests
  
  if (document.all||document.getElementById){
  document.write('<style id="tmpStyle" type="text/css">#pic {-moz-opacity:0.00;filter:alpha(opacity=0);opacity:0;-khtml-opacity:0;}<\/style>')
  var objG, degree=fadeAssist=0;
  if (document.all&&typeof document.documentElement!=='undefined')
  document.write('<!--[if GTE IE 5]><script type="text/javascript">fadeAssist=function (obj, degree){try {obj.filters.alpha.opacity=degree}catch(e){obj.style.filter="alpha(opacity="+degree+")"}}<'+'\/'+'script><![endif]-->')
  }
  
  function fadepic(obj){
  objG=obj
  if (!document.getElementById&&!document.all)
  return;
  var tS=document.all? document.all['tmpStyle'] : document.getElementById('tmpStyle')
  if (degree<100){
  degree+=5
  if (objG.filters&&objG.filters[0]&&fadeAssist)
  fadeAssist(objG, degree)
  else if (typeof objG.style.MozOpacity=='string')
  objG.style.MozOpacity=degree/101
  else if (typeof objG.style.KhtmlOpacity=='string')
  objG.style.KhtmlOpacity=degree/100
  else if (typeof objG.style.opacity=='string'&&!objG.filters)
  objG.style.opacity=degree/101
  else
  tS.disabled=true
  setTimeout("fadepic(objG)", 50)
  }
  else
  tS.disabled=true
  }  

  
  
  function toggleSlider() {
  if ($("#panelThatSlides").is(":visible")) {
  $("#contentThatFades").animate(
  {
  opacity: "0"
  },
  600,
  function(){
  $("#panelThatSlides").slideUp();
  }
  );
  }
  else {
  $("#panelThatSlides").slideDown(600, function(){
  $("#contentThatFades").animate(
  {
  opacity: "1"
  },
  600
  );
  });
  }
  }
  </script>  
  

Open in new window

0
Comment
Question by:rgb192
3 Comments
 
LVL 83

Accepted Solution

by:
Dave Baldwin earned 250 total points
ID: 39217130
Your file combines both regular javascript and jquery.  Are you loading the main jquery file before this one?

And I dont' see any PHP in what you posted.  I wouldn't do it that way, I would include that in the main HTML part of the page.
0
 
LVL 109

Assisted Solution

by:Ray Paseur
Ray Paseur earned 250 total points
ID: 39217479
JavaScript (including jQuery) runs on the client computer, not on your server.  The PHP script that prepares the HTML document runs on your server, but not on the client computer.  The PHP script must run first and be complete before the client computer can start to run the JavaScript.  PHP is used to generate HTML, JavaScript and CSS.  The process of generation can mean direct output into the browser stream like echo, or you can generate HTML statements that load other files, like <link> tags.

Since we do not have the PHP script in evidence here, it's hard to know how to advise you.
0
 

Author Closing Comment

by:rgb192
ID: 39217931
I include that in the main HTML part of the page.
and
i took out the
<script></script> in the js file and the javascript/jquery ran
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question