我的Js代码-按钮按下时判断是否选择了最后一行,给出提示

        <script language="javascript">
<!--
    
function onsub()
    {
        
//生成新月的字符串
        var nian=Number(document.all("ListBox1",0).value.substring(0,4));
        
var yue=Number(document.all("ListBox1",0).value.substring(4,6));
        
if(yue==12)
        {
            nian
=nian+1;
            yue
=1;
        }
        
else
        {
            yue
=yue+1;
        }
        
var stryue=""+yue;
        
if(yue<10)stryue="0"+stryue;
        
        
var newny=""+nian+stryue;
        
        
//判断是否已经存在
        
        
if(!(document.all("ListBox1",0).selectedIndex==document.all("ListBox1",0).length-1))  //不是最后一项
        {
            
if(document.all("ListBox1",0).options(document.all("ListBox1",0).selectedIndex+1).text==newny)
            
return confirm("您将要创建数据的月份 "+newny+ " 已经有数据存在,如果继续的话,将会删除原来数据再进行创建,是否继续?");
        }
    
        
return confirm("您将要创建 " +newny+" 的数据,是否继续?");
    }
!-->
        
</script>
posted @ 2005-09-12 17:06  jetz  阅读(615)  评论(0编辑  收藏  举报