I builded my own online javascript editor, but when I submit form, javascript not work. Here are my codes:
editor.php
<form action="show.php" method="post" target="window">
HTML code:<br />
<textarea name="html"></textarea><br />
JavaScript code:
<textarea name="javascript"></textarea><br />
<input type="submit" value="Test javascript" />
</form>
<iframe src="show.php" width="880" height="600" name="window"></iframe>
show.php
<html>
<head>
</head>
<body>
<?php
if(isset($_POST['html'])) echo $_POST['html'];
echo "<br><br>";
if(isset($_POST['javascript'])){
echo "<script>";
echo $_POST['js'];
echo "</script>";
}
?>
</body>
</html>
HTML works well, but when I say something in javascript textarea, javascript will not work in iframe. Please, help me.
From your code I see no input field with name js, hence I assume the following:
echo $_POST['js'];
should be:
echo $_POST['javascript'];
Otherwise, your code should work fine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With