You are here: Re: Assigning PHP var to Javascript « PHP Programming Language « IT news, forums, messages
Re: Assigning PHP var to Javascript

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

 

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

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