I try to create modular application, so each page have contains own html and javascript code. I supposed to load all code dynamically like:
var s = document.createElement("script");
s.type = "text/javascript";
s.src='function oncl() { alert("click");}';
$(".selector").append(s);
$( ".selector" ).
append('<input type="button" onclick="ocl();" />
<form action="../test/test_upload4.php"
method="POST" enctype="multipart/form-data" name="getnamefile">
<input type="file" id="uploadfile" name="uploadfile">
<input type="submit" id="Submit" name= "Submit" value="Upload"></form>');
But it doesn't work -Error: ocl is not defined. What can be the reason? If I understand correct in each webpage is an object that contains all javascript functions - so why not possible add or remove function to/from ?