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

Posted by David Williams on 10/30/07 00:29

Rik Wasmus <luiheidsgoeroe@hotmail.com> wrote:
Thank you so much Rik.

I still do not really understand but am going to study what you wrote.

The reason I kept overwriting was just to get this output
correct. In my final code, I am writing to an array different values.
But to take as much ambiguity out of the code that I could, I simplified
it to that.

Now, to the code:


echo "abc='".addslashes($temp_image_name)."';";

echo " blah "; // the code in its most simplest form
which outputed will be a Java statement
echo "abc= <blah>"; // if php does not talk to JS, how does
php know what abc is ?
The addslashes I suppose is to escape the double quotes around
the "Hello"? Why?

And the periods?

I know you have already helped but me understanding why would go
a long way.

Thanks a million.

David






> 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 ways
> > but the javascript variable will not take.
> >
> >
> > Thanks,
> > David
> >
> >
> > <script>
> > var abc
> > <?php
> > $sizeof_image_array=5;
> > for($i=0;$i<$sizeof_image_array;$i++)
> > {
> >
> > $temp_image_name="Hello";
> > echo 'abc=<?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 not
> required, it's a good idea to finish javascript lines with ';'.)

> echo "abc='".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

--
David Williams
Georgia Institute of Technology, Atlanta Georgia, 30332
Email: dw149@prism.gatech.edu

 

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

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