I am having problem tranferring a JavaScript varible to a PHP script. I am using the URL to transfer the varible:
preview.php?story=this%20is%20the%20text
It works fine for most characters except for the return character when using Internet Explorer for Mac. In IE, the return characters are removed. It works fine in Safari.
Like this forum, I replace tags with HTML code before it’s displayed. This is done using PHP in the preview.php script.
Does anyone have any suggections to precess the varible contents so it can survive the transfer to the PHP in all browsers.
The scripts for the two files are below:
<head>
….
<script language=”JavaScript” type=”text/JavaScript”>
<!–
var story;
function PreviewWin(story) {
story = story.replace(/&/g, ‘%26’);
story = story.replace(/ /g, ‘%20’);
window.open(‘preview.php?story=’ + story, ‘Preview’, ‘width=550,height=400,toolbar=no,menubar=no,status=no’);
}
//–>
</script></head>
….
<form name=”Create” id=”Create” method=”post” action=”newsletter.php”>
<textarea name=”story” cols=”75″ rows=”10″ id=”story”></textarea><br>
<input type=”button” name=”Preview” value=”Preview” onClick=”PreviewWin(document.Create.story.value);”>
</form>
The [b]preview.php
[code=php]<?php
// replace tags to create [b]bold[/b] etc.
echo nl2br(htmlspecialchars(stripslashes($story)));
?>
Thanks