Passing JavaScript Codes via PHP POST -


i have 2 textareas, iframe , submit button. in same page. want that; user code html , javascript codes in first textarea. second 1 hidden pass javascript codes. after user click submit button, s/he see results in iframe. saying w3school's trying page.

my submit button is:

<input type="submit" value="run codes" name="submit" onclick="sendthem()">  

my textarea's are:

<textarea id="textareacode1" style="width:100%;height:400px" name="code22" rows="21" wrap="logical" cols="42"><?=$code;?></textarea> //the user's textarea  <textarea  id="textareacode"  style="width:100%;height:400px" name="code"  rows="21" wrap="logical" cols="42"><?=$code;?></textarea> //this hidden (style="display:none;") 1 see happens, temporary made visible.  

and sendthem() function is:

function sendthem() { var t=document.getelementbyid("textareacode1").value; //the visible textarea t=t.replace(/</g,"smaller"); //string manipulation pass js codes via php post t=t.replace(/>/g,"greater"); //string manipulation pass js codes via php post t=t.replace(/=/g,"equal"); //string manipulation pass js codes via php post document.getelementbyid("textareacode").value=t; //manipulated code goes in hidden textarea document.getelementbyid("sampleform").submit(); //send form } 

and php code is:

<? $code = $_post['code']; echo "$code"; // here can see manipulated code "smallerhtmlgreater" ?><br/><? // try : $code = str_replace("greater", ">", $code); // reverse changes $code = str_replace("equal", "=", $code); $code = str_replace("smaller", "<", $code); printf("%s",$code); //and there no js codes.. tried echo or other php print commands also. ?> 

here screenshot http://i57.tinypic.com/sghcba.png (i hope helps)

now.. think problem in php part. can tell me why can't see js part of code, after reversing changes ?

and please, don't want change codes jquery or ajax etc.. want fix code. in advance...


Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

angularjs - ng-repeat duplicating items after page reload -