﻿//用于区分一个条件的多次选择
function GetDateTimeSymbol() {
    //获取日期 2007-04-29 16:41
    var now = new Date(); //获取系统日期，即Sun Apr 29 16:41:48 UTC+0800 2007 
    var yy = now.getYear(); //获取年，即2007 
    var mm = now.getMonth() + 1; //获取月，即04 
    var dd = now.getDay(); //获取该天的星期值 
    //获取时间 
    var hh = now.getHours(); //获取小时，即16 
    var mi = now.getMinutes(); //获取分钟，即41 
    var ss = now.getTime() % 60000; //获取时间，因为系统中时间是以毫秒计算的，

    return hh + "_" + mi + "_" + ss
}

//用于区分一个条件的多次选择
function GetDateTime() {
    //获取日期 2007-04-29 16:41
    var now = new Date(); //获取系统日期，即Sun Apr 29 16:41:48 UTC+0800 2007
    var yy = now.getFullYear(); //获取年，即2007 
    var mm = now.getMonth() + 1; //获取月，即04
    var dd = now.getDate(); //获取该天的星期值 
    //获取时间 
    var hh = now.getHours(); //获取小时，即16 
    var mi = now.getMinutes(); //获取分钟，即41 
    var ss = now.getSeconds(); //获取时间，因为系统中时间是以毫秒计算的，

    return yy + "-" + mm + "-" + dd + " " + hh + ":" + mi + ":" + ss;
}

function GetRandom(len) {
    return Math.round(Math.random() * Math.pow(10, len));
}

 
    //判断某个值是否存在
    function IsExistInSelect(sl,v)
    {
        for(var no=0;no<sl.options.length;no++)
        {            
            if ( v == sl.options[no].value)
            {
               return true;
            } 
        }
        
        return false;
    }
    
    function IsLikeExistInSelect(sl,v)
    {
        for(var no=0;no<sl.options.length;no++)
        {            
            if ( sl.options[no].value.indexOf(v) > -1)
            {
               return true;
            } 
        }
        
        return false;
    }
    
    //获得下拉框所有选项字符纯
    function GetAllSelectItem(sl)
	{
	    var returnStr = "";
	    
	    for(var no=0;no<sl.options.length;no++)
        {            
            if (sl.options[no].value != "")
            {
                returnStr += sl.options[no].value + "|";
            } 
        }  
        
        return returnStr;
	}
	
	function GetAllSelectItemWithText(sl)
	{
	    var returnStr = "";
	    
	    for(var no=0;no<sl.options.length;no++)
        {            
            if (sl.options[no].value != "")
            {
                returnStr += sl.options[no].value + "," + sl.options[no].text + "|";
            } 
        }  
        
        return returnStr;
	}
	
    //获得某个索引
    function GetOptionIndex(sl,v)
	{
	    for(var no=0;no<sl.options.length;no++)
        {            
            if ( v == sl.options[no].value)
            {
                return no;
            } 
        }
    }

    //设置某个索引
    function SetOptionIndex(sl, text) {
        for (var no = 0; no < sl.options.length; no++) {
            if (text == sl.options[no].text) {
                sl.value = sl.options[no].value;
            }
        }
    }
	
	//获得选中文本信息
    function GetSelectText(sl)
	{
	   return sl.options[GetOptionIndex(sl,sl.value)].text;
	}

	//给下拉框增加单个项目
	function AddSingleItemForSelect(sl, value, text) {  //window.alert("给下拉框增加单个项目");
        try
        {
            sl.add(new Option(text,value));
        }
        catch(e)
        {
            sl.options.add(new Option(text,value));
        }
    }
    
    //删除下拉框指定选项
    function  DelSingleItemForSelect(sl,value)
    {
        sl.remove( GetOptionIndex(sl,value) );
    }
    
    //给下拉框增加项目
    function  AddItemForSelect(sl,str)
    {
        var arr = str.split('|');
	    for(var i=0 ; i < arr.length;i++)
	    {
	        if (arr[i] != "" )
	        {
		        sl.add(new Option(arr[i].split(',')[1],arr[i].split(',')[0]));
		    }
	    }
    }
    
    //清除下拉框项目
    function ClearItemForSelect(sl)
    {
        while(sl.options.length > 0)
		{
			sl.remove(0);
		}
    }