Re: Got JavaScript error when using PHP's include()...
| From: | Scott Fletcher | Date: | Fri, 16 Jul 2004 13:52:35 +0000 |
| Subject: | Re: Got JavaScript error when using PHP's include()... | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-190710@lists.php.net to get a copy of this message | ||
Oh never mind... I looked up at
http://us3.php.net/manual/en/function.include.php
and saw this...
--snip--
When a file is included, parsing drops out of PHP mode and into HTML mode at
the beginning of the target file, and resumes again at the end. For this
reason, any code inside the target file which should be executed as PHP code
must be enclosed within valid PHP start and end tags.
--snip--
So by moving those over to PHP like this solve my problem...
--snip--
<?
echo "<script type='text/javascript'>";
blah blah
?>
--snip--
FletchSOD
"Neal Owen" <apathetic@mrichi.com> wrote in message
news:1089928699.4636.1.camel@neal.mrichi.com...
> You defined jsTest after the include where it should be before.
>
>
> On Thu, 2004-07-15 at 16:24, Scott Fletcher wrote:
> > When an include file contain plain JavaScript codes, with the echo
command
> > before and after the include file. I get the javascript error saying
> > "undefined jsTest"... Anyone know why is that?
> >
> > --snip--
> > echo "<table><tr><td></td></tr></table>";
> > echo "<script type='text/javascript'>";
> > include('test.inc');
> > echo " var jsTest = 0; ";
> > echo "</script>";
> > echo "<form><input type='button></form>";
> > --snip--
> >
> > Let's say the script in the test.inc contain
> >
> > --snip--
> > function test() {
> > if (jsTest != 0) {
> > //blah blah balh...
> > }
> > }
> > --snip--
> >
> > Thanks,
> > FletchSOD
> --
> Neal Owen | IT Programmer
> Marketing Resources, Inc.
> Main : 312.238.8923 x1218
> Direct : 630.592.3118
>
> nowen@mrichi.com | http://www.mrichi.com