You are here: Outputting variables in javascript confusion « PHP Programming Language « IT news, forums, messages
Outputting variables in javascript confusion

Posted by andy.z on 03/09/07 17:50

I'm confused -

The following outputs a URL encoded string into an alert box
----------------------CUT ----------------------
function createEmbarrasment() {
$tmp = urlencode("Your fly is undone!");
?> <script type="text/javascript"><!--
alert('<?php echo $tmp; ?>')
//--> </script>
<?php
}
-------------------------------
Unfortunately displaying the URL encoded version of the string

If you remover the URL encoding the alert box doesn't even display

Next

Using constants - Again this fails to even open the alert box
----------------------CUT ----------------------

function createEmbarrasment() {
define("TEMP","Your fly is undone!");
?> <script type="text/javascript"><!--
alert('<?php echo TEMP; ?>')
//--> </script>
<?php
}
-------------------------------

AND YET

----------------------CUT ----------------------
function createEmbarrasment() {
?> <script type="text/javascript"><!--
alert('<?php echo PHP_VERSION; ?>')
//--> </script>
<?php
}
-------------------------------
Opens the box and displays fine without URL encoding

MY PROBLEM - I'm trying to do the first example without the display
showing the URL encoding.


Can anyone explain or help please?

-andy-

 

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

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