|
Posted by d on 10/09/88 11:38
"Pablito" <pablito@nonspam.com> wrote in message
news:EZ4Df.68327$eD5.1162011@twister2.libero.it...
>
> "jamen" <jamen@invalid> ha scritto nel messaggio
> news:43dcc9ca$0$2086$edfadb0f@dtext02.news.tele.dk...
>> Pablito wrote:
>> > can I pass a $var maked with PHP to javascript
>>
>> of course..
>>
>> <script type="text/javascript">
>>
>> var jsvar = <?php echo $phpvar ?>;
>>
>> </script>
>
> I thank you very much but my script is this and it is like your but do
> not
> work
> Why?
>
>
> <?php
> $cont=fopen('cont.txt','r');
> $incr=fgets($cont);
> //echo $incr;
> $incr++;
> fclose($cont);
> $cont=fopen('cont.txt','w');
> fwrite($cont,$incr);
> fclose($cont);
> echo "<script type="text/javascript">
> var incr=$incr
> </script>";
> ?>
You need to escape the quotes in your <script> tag:
echo "<script type=\"text/javascript\">
var incr=$incr;
</script>";
(and note the semi-colon after the var line). You might also want to put
'language=javascript' in the script tag, too, just to be on the safe side ;)
How are you using that javascript variable?
> Pablito
dave
Navigation:
[Reply to this message]
|