Re: PHP / JavaScript integration

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Mar 09, 2005 at 12:27:39AM +0000, M?rio Gamito wrote:
> Hi,
> 
> I'm trying to integrate some JavaScript functions in PHP, but so far, no 
> good :(
> 
> I want to have a js.php file that has the JavaScript functions i want to 
> use. This file, albeit its extension, has no PHP code or even tag.
> 
> It's just like this:
> 
> js.php
> --
> <script language="JavaScript">
> 
> function def(word) {
>     if (word == 'all_not_filled') {
>         type = 'error1';
>         definition = 'You didn't filled all form fields.';
>     }
> myFloater = 
> window.open(filename,'myWindow','scrollbars=no,status=no,width=300,height=200')
> }
> 
> </script>
> --
> 
> Now... i want to call this JavaScript function from the regular PHP files.
> In particular, before the HTML code.
> Like this:
> 
> index.php
> --
> 
> <?php
> 
>  if (condition)
>   def('all_not_filled') // def is a JS function in js.php
> 
> ?>
> 
> <HTML>
>  <HEAD>
> 
> (...)
> 
> </HTML>
> --
> 
> How can i do this ?
> How to tell PHP, that def(word) is a JS function in js.php file ?
> I've tried include ('js.php'), etc., but got no results :(

why not use a script include instead of a php one?  ie: 

<script language="javascript" src="js.php">

from inside your index.php page? 
seems to make sense, since there is no php in the js file.  
just a thought, 
gabe.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux