向服务器回送方式:
<html> 
<head> 
</head> 
<body> 
<form   action   =   "index.php"   method="post"> 
<input   type="text"   id="myvalue"   name="myvalue"   value=""> 
<button type="submit">提交</button>
</form> 
<div   > 
<?php 
$myValue   =   $_POST["myvalue"]; echo   " <input   type='text'   value   =   '$myValue'> "; 
?> 
</div> 
</body> 
</html> 
----------------------------
动态javascript
<html> 
<head> 
<script>
var handleOnchange = function()
{
    document.getElementById('sec').value = document.getElementById('myvalue').value;
}
</script>
</head> 
<body> 
<form   action   =   "index.php"   method="post"> 
<input   type="text"   id="myvalue"   name="myvalue"   value="" onchange="handleOnchange"> 
</form> 
<div   > 
<?php 
$myValue   =   $_POST["myvalue"]; echo   " <input   type='text'   value   =   '$myValue' id="sec"> "; 
?> 
</div> 
</body> 
</html> 

解决方案 »

  1.   


    function parsespecialchars($variable)
    {
       return str_replace( array('&', '<', '>', '"', "'"), array('&#38;', '&#60;', '&#62;', '&#34;', '&#39;'), $variable );
    }
      

  2.   

    function parsespecialchars($variable)
    {
       return str_replace( array('&', '<', '>', '\"', "\'"), array('&#38;', '&#60;', '&#62;', '&#34;', '&#39;'), $variable );
    }谢谢,我把你给的函数作一点改动.这样就行了.但我还是有个发问,如果这样搞下去,要替换的字符很多的情况下,岂不是这个函数很长?!
      

  3.   

    <html>
    <head>
    </head>
    <body>
    <form  method="post">
    <input   type="text"   id="myvalue"   name="myvalue"   value="">
    </form>
    <div   >
    <?php
    $myValue   =   stripslashes($_POST["myvalue"]);
    echo "<textarea>$myValue</textarea>";
    ?></div>
    </body>
    </html>