Solved

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

Posted on 2013-06-03
3
541 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

808 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