php - Textarea not updating when passed a string with a newline from POST? -



php - Textarea not updating when passed a string with a newline from POST? -

i'm running troubles code, narrowed downwards , simplified in 2 next segments:

index.html

<html> <body> <form name="form" method="post" action="upload.php" target="iframe"> <textarea id="text1" name="text1"></textarea> <input type="submit" /> </form> <textarea id="text2"></textarea> <iframe name="iframe" id="iframe" style="display:none;" ></iframe> </body> </html>

upload.php:

<?php $message= $_post['text1']; echo <<<_end <script language="javascript" type="text/javascript"> var pardoc = window.parent.document; pardoc.getelementbyid('text2').value = '$message'; </script> _end; ?>

the overall goal of code above nowadays in text2, submitted text1. works exception of message in text1 contains newlines. when attempting submit message newlines text2 not updated. can't seem trace error , i'm stuck in mental rut one. ideas? again, simplified version of overall code. whittled error downwards problem.

try in upload.php

<?php $message= nl2br($_post['text1']); $message = str_replace("\r\n",'',$message); echo ' <script language="javascript" type="text/javascript"> var pardoc = window.parent.document; var text = "' . $message . '"; text = text.replace(/<br \/>/ig,"\\n"); pardoc.getelementbyid("text2").value = text; </script>'; ?>

php html http post textarea

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

c# - Can ProtoBuf-Net deserialize to a flat class? -

javascript - Change element in each JQuery tab to dynamically generated colors -