PHP / JavaScript integration
| From: | Mário Gamito | Date: | Wed, 09 Mar 2005 00:27:39 +0000 |
| Subject: | PHP / JavaScript integration | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-210271@lists.php.net to get a copy of this message | ||
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 :(
Any help would be apreciated.
Best regards,
Mário Gamito