You are here: Re: php n javascript « PHP Programming Language « IT news, forums, messages
Re: php n javascript

Posted by noone on 02/05/06 23:55

Leszek wrote:
> Hi
> I have a problem while inserting php code into javascript
>
> var danevar1 = '<?php echo $dane1; ?>';
>
> this line doesn't work
> i tried also:
> var danevar1 = '<? echo $dane1; ?>';
> and
> var danevar1 = '<?= echo $dane1; ?>';
>
> but it's not working
>
> Can anyone help my with it?
> Leszek
>
>

are you define $dane prior to sending the header containing the javascript?

Simple test...

---------cut here----------------
<?php $dane = "123";?>
<html>
<head>
<script type="text/javascript?>
function xyz(a){
var='<? echo $dane; ?>'
return true
}
</script></head>
</html>
---------------cut here---------

view source shows:

<html>
<head>
<script type="text/javascript?>
function xyz(a){
var='123'
return true
}
</script></head>
</html>


Works for me, so my guess is that you are not defining $dane before you
are trying to output it...


M.

 

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

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