在我的网页下方,CalcModule.func2() 函数中的一些代码将错误消息写入 id=errorbox 的 div 元素。我的问题是,当我将此 div 元素放在表单 (myForm) 上方时,当 CalcModule.func2() 函数写入错误消息时,整个页面都会被擦除。只有当我将 div 错误框元素放在表单下方时(参见代码),页面才不会被删除。
我哪里错了?
<head>
<title></title>
<script>
function CalcModule(){};
//some vars
CalcModule.var_a;
CalcModule.var_b;
//etc.
//some functions
CalcModule.func1 = function(msg){
}
CalcModule.func2 = function(){
if(!selected){ //no checkbox selected?
$("#errorbox").removeClass("success");
$("#errorbox").addClass("error");
$("#errorbox").html("errormessage");
}
else{
$("#errorbox").removeClass("error");
$("#errorbox").html("");
}
}
//etc.
$(document).ready(function(){
$("#myForm").validate({})
$.get("process.php", //ajax call
function(msg) {
var form = Getform(msg);
$("#wrapper").append(form);
}
)
}//$(document).ready(function
</script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<!-- ideally the '<div id="errorbox"><div>' should be at this location, but that does not work-->
<form id="myForm" name="myForm" action="" method="post" autocomplete="on">
<!--some table html code here-->
<div id="wrapper"></div> <!--anchor point for adding set of form fields -->
<input type="submit" name="submitForm" value="Submit Form">
</form>
<div id="errorbox"><div> <!--this seems the only location for this div on the page where the page is not erased-->
</body>