I want to have a textarea or an input where a user can write javascript code and save it (by clicking a button). Once the code is saved, it is inserted in a script and when the user clicks on "run" button then the code that he/she typed will work.
Here is an example if I wasn't specific enough:
<html>
<body>
<input id="editor" value="add some code here">
<!-- lets say a user types some code: -->
alert("hey");
</input>
<button id="saveBtn">Save the code</button>
<button id="runBtn">Run the code</button>
<script src='the_code_of_the_user'></script>
<script>
//Here I will just write some pseudo code because i have no idea how to do this
saveBtn.onclick = function() {
editor.insert to Script('the_code_of_the_user');
}
runBtn.onclick = function() {
run Script('the_code_of_the_user');
}
</script>
</body>
</html>