Reply to Re: Outputting variables in javascript confusion

Your name:

Reply:


Posted by Jeff North on 03/10/07 01:02

On Fri, 09 Mar 2007 17:50:48 GMT, in comp.lang.php
andy.z@blueyonder.com
<MPG.205baf093be9d698997d@news-text.blueyonder.co.uk> wrote:

>|
>| 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
>|

Javascript alert boxes are plain text. So if you use
alert("This is line 1<br />This is line 2");
then This is line 1<br />This is line 2 will be displayed

To show the above correctly you need
This is line 1\nThis is line 2

Change your $tmp variable to
$tmp = "Your fly is undone!";
---------------------------------------------------------------
jnorthau@yourpantsyahoo.com.au : Remove your pants to reply
---------------------------------------------------------------

[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

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