以下是引用szeee在2005-10-8 16:51:00的发言:
我看段程序
<script language=javascript runat=server>
function chkFields() {
if(document.Myform.UserName.values=='') {
windows.alert("请输入用户名")
return false
}
return true
}
</script>
这里的
return false return true 起什么作用啊?必须要它们吗?

 
JavaScript中的作用就是使if语句后不会执行后面的代码光讲楼主也不会明白
《script language=javascript》
function testfalse()
{
        var a;
        var b;
        a=1;
        b=1;
       if(a==1)
       {
           alert("a=1");
        }
        if(b==1)
          {
              alert("b=1");
           }
}
《/script》
《INPUT title=点一下试试 onclick=testfalse(); type=button value=command1 name=button》 
 
上面是不加return false的代码,楼主试试效果。
加了return false再试试。
《script language=javascript》
function testfalse()
{
        var a;
        var b;
        a=1;
        b=1;
       if(a==1)
       {
           alert("a=1");
            return false;
        }
        if(b==1)
          {
              alert("b=1");
              return false;
           }
}
《/script》
《INPUT title=点一下试试 onclick=testfalse(); type=button value=command1 name=button》