You are here: Re: [PHP] PHP / JavaScript integration « PHP « IT news, forums, messages
Re: [PHP] PHP / JavaScript integration

Posted by Richard Lynch on 10/04/07 11:10

> 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

You can't do that.

You could do this:
<?php
require 'def.js';
if (...) echo "def('all_not_filled');";
?>

Then, when the page gets sent to the browser, the def() function gets
called by the browser.

PHP runs on your server.

JavaScript is run by the browser, on the web surfer's computer, millions
of miles away, and long after PHP has finished its work and gone away.

--
Like Music?
http://l-i-e.com/artists.htm

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация