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:55

Shelly <sheldonlg.news@asap-consult.com> wrote:
Hi Shelly,
Clearly, the <?php ?php> tag way is wrong as Rik pointed out.
I was thinking that I had the <script></script> tags outside of the
initial <? ?> tags and I was writing Javascript ( the abc part ) so I needed
to get the php back out. Rik has said to think of php as writing javascript statements
..

Yes, I know, convouluted. I need a very good tutorial on how to mix javascript and
php but have not found one yet.

Also, the reason it is in a loop is because this was for testing purposes.
The real code writes a different value to diff vars.

Thanks for any more critiques.

David

And, I was trying to assign a php var value
> "David Williams" <dw149@acmex.gatech.edu> wrote in message
> news:fg5rk9$be5$1@news-int.gatech.edu...
> >
> > 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;?>;';
> > echo 'alert(abc);';
> >
> > }
> > ?>
> > </script>
> >

> Why do you have <?php followed by <?php ? Don't you mean

> echo 'abc = "' . $temp_image_name . '";' ;

> Also, why is this in a loop?

> Shelly



--
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

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