Reply to Re: How to add some text to an input box with PHP

Your name:

Reply:


Posted by J.O. Aho on 10/10/40 11:32

Stefan Mueller wrote:

> I try the following code on my PHP server but the browser says syntax error
> in 'var MyJSVariable = ;'
> I guess that '<? echo $MyPHPVariable; ?>' gets translated to nothing because
> my PHP variable is empty at the beginning:

Yeah, you are right.


> ==========================
> <html>
> <head>
> <script type = "text/javascript">
> function PageIsLoaded() {
> var MyJSVariable = <? echo $MyPHPVariable; ?>;
> alert(MyJSVariable);
> }
> </script>
> </head>

At this point $MyPHPVariable is empty and what you are doing is really
var MyJSVariable = ;

> <body onLoad = "PageIsLoaded()">
> <?php
> $MyPHPVariable = "some text";
> ?>
> </body>
> </html>

Now you have set the value for the variable, but it will only affect things
that are done after this stage.


//Aho

[Back to original 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

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