Welcome to WebmasterWorld Guest from 54.196.246.145

Forum Moderators: open

Message Too Old, No Replies

javascript escape and unescape

how to implement javascript escape and uescape functions

     
7:28 am on May 23, 2003 (gmt 0)

New User

10+ Year Member

joined:Apr 21, 2003
posts:4
votes: 0


hello there! i am having problem in calling the escape and unescape functions.

i have a button in my form which opens a new window. upon clicking the said button, it should pass the string $title to the new window thru url. however, the string accepts special characters. i believe that strings with special characters must be escaped first then unescape (to the new window) for it to be displayed properly.

here is a sample of the code: (php)

$title = $results["Title"];

<form name="modify" method="post">

<input type="text" name="Title" size="50" value=" <? echo $title;?> ">
<input type="button" name="pick" value="Send" onClick = "window.open('modtitle.php?OpenForm&title=<? echo $title?>&actione=load','new_win','width=400,height=300');">

</form>

the problem: where will i insert the function that will escape the string $title that will be passed thru url.

on the other hand, at my new child window, the string $title must be placed in a textarea.

<textarea name="Title" cols="51" rows="5"><? echo $title?></textarea>

the problem: how will i unescape the string $title to display it in the textarea in my new window.

please help....

5:07 pm on May 23, 2003 (gmt 0)

Administrator

WebmasterWorld Administrator jatar_k is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:July 24, 2001
posts:15755
votes: 0


hey Tanya,

Have you thought about trying it with php? Something like this might work

$title = $results["Title"];
$esctitle = addslashes [ca.php.net]($title);

<form name="modify" method="post">

<input type="text" name="Title" size="50" value=" <?= $title;?> ">
<input type="button" name="pick" value="Send" onClick = "window.open('modtitle.php?OpenForm&title=<? echo $esctitle?>&actione=load','new_win','width=400,height=300');">
</form>

<textarea name="Title" cols="51" rows="5"><?= stripslashes [ca.php.net]($title)?></textarea>

I slipped a little shorthand in there too, this
<? echo $title;?>
is the same as
<?= $title;?>

just a little tighter code for echoing vars. Give that a try and, if not, come back and we'll see what else we can dig up.

7:02 am on May 26, 2003 (gmt 0)

New User

10+ Year Member

joined:Apr 21, 2003
posts:4
votes: 0


hi there! the code doesn't seem to work. the <? = $title;?> creates parse error so i have to use echo instead.

anyway, i found a solution to my problem... i need not have to use the escape and unescape function. i just have to use URLEncode($title) to view the special characters correctly in the new window. thank you so much.

 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members