一、复选框的全选:
<script language="JavaScript">
function CheckAll(form)
{
for (var i=0;i<form.elements.length;i++)
{
var e = form.elements;
if (e.name != 'chkall' )
e.checked = form.chkall.checked;
}
}
</script>
全选 <input name="chkall" type="checkbox" id="chkall" value="on" οnclick=CheckAll(this.form)>
二、表单的检查:
<form name="form1" method="post" action="" onSubmit="return checkdata()">
<script language="javascript">
<!--
function checkdata()
{
if (document.form1.email.value=="")
{
window.alert("请输入你的E-mail地址!");
return false;
}
if (document.form1.password.value=="")
{
window.alert("请输入你的密码!");
return false;
}
if (document.form1.password.length<5)
{
window.alert("你的密码必须大于4位!");
return false;
}
if (document.form1.password.length>16)
{
window.alert("你的密码必须小于16位!");
return false;
}
if (document.form1.confirmpassword.value=="")
{
window.alert("请输入你的确认密码!");
return false;
}
if (document.form1.password.value!=document.form1.confirmpassword.value)
{
window.alert("两次输入的密码不一致!");
return false;
}
if (document.form1.name.value=="")
{
window.alert("请输入你的姓名!");
return false;
}
return true;
}
//-->
</script>
<script language="JavaScript">
function checkdata()
{
if (document.form1.title.value=="")
{
window.alert("请输入标题!");
return false;
}
if (document.form1.content.value=="")
{
window.alert("请输入正文内容!");
return false;
}
}
</script>
将以下代码添加至表单的form标签中:
onSubmit="return checkdata()"
三、对话框确认并网页重定向或返回:
<script language="javascript">
alert("感谢你的点击!");
self.location="*.asp"
</script>
<script language="javascript">
alert("感谢你的点击!");
history.go(-1);
</script>
四、删除确认:
javascript:if(confirm('确定要删除吗?')) window.navigate('delete.asp?id=<%= rs("id") %>')
javascript:if(confirm('确定要删除吗?')) window.navigate('delete.jsp?id=<%= rs.getString("id") %>')
javascript:if(confirm('确定要删除吗?')) window.navigate('delete.aspx?id=<%# DataBinder.Eval(Container.DataItem,"id") %>')
五、返回上一页: javascript:history.back()
六、按钮事件:
οnclick="javascript:window.navigate('*.asp');"
οnclick="history.back()"
七、跳转菜单:
<select name="showPage" onChange="javascript:window.location='rsnav.asp?showPage='+this.options[this.selectedIndex].value;">
<input name="Submit" type="button" onClick="MM_jumpMenuGo('menu1','parent',0)" value="查询">
<input name="Submit" type="button" onClick="javascript:window.open(menu1.options[this.selectedIndex].value);" value="查询">
window.open('url.aspx');
<script type=text/javascript> </script> <script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type=text/javascript> </script> <script> window.google_render_ad(); </script>