Hi to all, I was wandering if I can do the following thing:
I need a page that I can input a piece of script:
e.g.

<script>
function Test(mystring)
{
if (mystring !="")
alert("OK");
else
alert("NotOK");
}
</script>

And click a button and run the script in the page.
The Script can be anything.

I found a way to insert a script in my page like

//mydiv is the place were I want to inser the page
var ni = document.getElementById('myDiv');
//create script object
var element = document.createElement('script');
//set attribute src with the script I insert
element.setAttribute("src",strScript);
ni.appendChild(element);

The problem is that the above piece code insert the script in the page, but doesn't run it.
I can see that the script was added, but nothing happens
Help, Thanks

<input type="button" onclick="javascript: Test(mystring)" name="clickMe" value="Update Now!" />

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.