Whenever I click the execute button, I encounter an error in my console stating "Uncaught ReferenceError: execute is not defined". During onclickng, I am dynamically creating an input box and a button.
<!DOCTYPE html>
<html lang="en=US">
<head>
<meta charset="utf-8"/>
<title>Create Course</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<input id="textbox" type="text" /><br><br>
<!-- A function is declared here--> <button id="numFiles" onclick="execute()">execute</button><br> <!-- The error is visible at this point-->
<form method = "POST">
<p id="status"></p>
</form>
<script>
This is where the execute() function is defined:
{
var NumFiles = document.getElementById("textbox").value;
var i=1;
while(NumFiles>0)
{
var input = document.createElement("Input");
input.type = "text";
input.id = i;
var exp = document.body;
exp.appendChild(input);
var br = document.createElement("br");
document.body.appendChild(br);
var br1 = document.createElement("br");
document.body.appendChild(br1);
NumFiles = NumFiles-1;
i=i+1;
}
var x = document.createElement("INPUT");
x.setAttribute("type", "button");
x.setAttribute("id","sub");
}
</script>
</body>
</html>
I have attempted to use different names but still receive the same error. Any insights on how to resolve this issue?