|
|
Posted by Rik Wasmus on 10/30/07 00:02
On Tue, 30 Oct 2007 00:50:33 +0100, David Williams =
<dw149@acmex.gatech.edu> wrote:
>
> Can anyone see why the javascript var abc here is not getting assigned=
> the php var ("Hello")? in my code? I have tried a lot of different w=
ays
> but the javascript variable will not take.
>
>
> Thanks,
> David
>
>
> <script>
> var abc
> <?php
> $sizeof_image_array=3D5;
> for($i=3D0;$i<$sizeof_image_array;$i++)
> {
>
> $temp_image_name=3D"Hello";
> echo 'abc=3D<?php echo $temp_image_name;?>;';
Well, look at your source. What's the output here? And even if it would =
=
work, why would you keep overwriting the abc variable? (BTW: allthough n=
ot =
required, it's a good idea to finish javascript lines with ';'.)
echo "abc=3D'".addslashes($temp_image_name)."';";
Keep in mind PHP does _NOT_ communicate with javascript. It will output =
=
something that could be valid javascript, but doesn't care wether it's =
javascript, the latest budget report or some very deep poetry.
-- =
Rik Wasmus
[Back to original message]
|