[英]How do I fix Expected end of Statement?
How would I fix,"Expected End Of Statement" in the code below? 如何在下面的代码中修复“预期的语句结尾”?
<script type="text/javascript">
function substitute() {
var myValue = document.getElementById('myTextBox').value;
if (myValue.length === 0) {
alert('Please enter a real value in the text box!');
return;
}
var myTitle = document.getElementById('title');
myTitle.innerHTML = myValue;
}
</script>
It keeps telling me line 57 which is this line: 它不断告诉我第57行,这行是:
<input type="submit" value="Click Me" onClick="substitute();">
Here is the complete HTA link: http://pastebin.com/fMg5e4RN 这是完整的HTA链接: http : //pastebin.com/fMg5e4RN
Use <form onsubmit="return substitute()"
and return true or false depending on validation. 使用
<form onsubmit="return substitute()"
并根据验证结果返回true或false。 Remove type="javascript" or fix it as text/javascript 删除type =“ javascript”或将其修复为text / javascript
<script type="text/javascript">
function substitute() {
var myValue = document.getElementById('myTextBox').value;
if (myValue.length === 0) {
alert('Please enter a real value in the text box!');
return false;
}
// not sure what the following two lines are for
var myTitle = document.getElementById('title');
myTitle.innerHTML = myValue;
return true; // allow submit
}
</script>
and use 和使用
<form action="some action" onsubmit="return substitute();">
<input type="text" id="myTextBox"/>
<input type="submit" value="Click Me" />
</form>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.