homepage Welcome to WebmasterWorld Guest from 54.161.228.29
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

    
javascript escape and unescape
how to implement javascript escape and uescape functions
Tanya




msg:1478120
 7:28 am on May 23, 2003 (gmt 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....

 

jatar_k




msg:1478121
 5:07 pm on May 23, 2003 (gmt 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.

Tanya




msg:1478122
 7:02 am on May 26, 2003 (gmt 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.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved