我刚开始使用 Javascript,但在页面加载事件上遇到了麻烦。提交form1后,应该会出现form 2。
<html>
<head>
<script src="jquery1.9.1.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="sCss.css">
</head>
<script type="text/javascript">
function hide( obj1 ) {
obj1 = document.getElementById( obj 1);
if ( document.cookie.indexOf('mycookie') == -1 ) {
document.cookie = 'mycookie = 1';
obj1.style.display = 'none';
} else {
obj1.style.display = 'block';
}
}
function show( obj2 ) {
var cookie = "test"
obj2 = document.getElementById( obj2 );
obj2.style.display = 'block';
document.cookie = 'mycookie = 1';
}
</script>
<body onload="hide('form2')">
<form id="form1" onsubmit="show('form2')">
<table id="table1" border="1" >
<tr>
<td>
<input type="text" name="txt1" id="txt1" />
</td>
<td>
<input type="submit" name="submit1" id="submit1" />
</td>
</tr>
</table>
</form>
<form id="form2">
<table id="table2" border="1" >
<tr>
<td>
<input type="text" name="txt2" id="txt2" />
</td>
<td>
<input type="submit" name="submit2" id="submit2" />
</td>
</tr>
</table>
</form>
</body>
</html>
基于给出的代码。点击form1的提交按钮后,form2立即出现又消失。