Saturday, 14 September 2013

jquery html() erases webcontent

jquery html() erases webcontent

On my webpage below some code within the CalcModule.func2() function
writes error messages to a div element with id=errorbox. My problem is
that when I place this div element above the form (myForm), the entire
page is erased when CalcModule.func2() function writes an error message.
Only when I place the div errorbox element below the form (see code) the
page is not erased.
Where do I go wrong?
<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>

No comments:

Post a Comment