您好我正在提交调查问卷并尝试使用onSubmit获取结果,但它无效
的JavaScript
function results_addition(){
var results = total + Details + formElement;
if(results<30){
document.submit_form.choice1.value="Low Risk";
}else{
if(results>50){
document.submit_form.choice1.value="High Risk";
}else{
document.submit_form.choice1.value="Medium Risk";
}
}
}
HTML
<form name="choice1" onSubmit="results_addition()">
<input type="submit" value="Submit">
答案 0 :(得分:0)
请尝试onsubmit
代替onSubmit
,然后添加结束</form>
代码
答案 1 :(得分:0)
<html>
<body>
<p>When you submit the form, a function is triggered which alerts some text.</p>
<form name="choice1" onSubmit="results_addition()">
<input type="submit" value="Submit">
</form>
<script>
function results_addition(){
alert("hello")
}
</script>
</body>
</html>
我尝试了相同的表单并且正在运行我认为您还没有正确关闭表单。
答案 2 :(得分:0)
更改
<form name="choice1" onSubmit="results_addition()">
到
<form name="choice1" onSubmit="return results_addition()">
在函数末尾添加以下内容
return false;