I used execute function on click of execute button.But while clicking on this button I am getting "Uncaught ReferenceError: execute is not defined"
error in my console. onclickng I am creating input box and button.
我在点击执行按钮时使用了执行功能。但是在点击此按钮时,我在控制台中收到“未捕获的ReferenceError:执行未定义”错误。 onclickng我正在创建输入框和按钮。
<!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>
<!-- here i declare function--> <button id="numFiles" onclick="execute()">execute</button><br> <!-- in console there are showing me error here-->
<form method = "POST">
<p id="status"></p>
</form>
<script>
here i used-- function execute()
{
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 tried with change different name but still getting same error. any idea about this kind of error??
我尝试更改不同的名称,但仍然得到相同的错误。关于这种错误的任何想法?
1 个解决方案
#1
2
Try putting your script in the head tag, instead of body. Also, try to force a refresh to clean the Cache.
Windows - Ctrl+F5
Mac - Command+shift+R
尝试将脚本放在head标签中,而不是正文。此外,尝试强制刷新以清理缓存。 Windows - Ctrl + F5 Mac - Command + shift + R.
#1
2
Try putting your script in the head tag, instead of body. Also, try to force a refresh to clean the Cache.
Windows - Ctrl+F5
Mac - Command+shift+R
尝试将脚本放在head标签中,而不是正文。此外,尝试强制刷新以清理缓存。 Windows - Ctrl + F5 Mac - Command + shift + R.