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.