// JavaScript Document

function select_next2(str)
   {
		
		var retstr;
		var readflag;
		var newsubstr='';
		var read_strlen=0;
		var myurl;
		var sarray=new  Array();
		
		var url;
	    url=window.location.href;
        //alert(window.location.href);
        var point;
	    point=url.lastIndexOf('/')+1;
        var strstr= url.substring(0,point);
        //url 除过最后的文件------------------
	    //alert(strstr);
		
		infoBoard=document.getElementById("displayInfo"); 
        infoBoard.innerText='查询中...'; 
        myurl=strstr+"select_next2.php?database_id="+str;
        //myurl="http://127.0.0.1:8080/check_correct_answer.asp?id="+get_id;
		//alert(myurl);
		
		retstr=openUrl(myurl); 
		
        //alert("服务器返回值："+retstr);
		//全部删除------------------------
		delete_all_select();
		
		//读标志-----------------------------------
		readflag=retstr.substring(0,1);
		
		//去掉头部的1----------------------------
		read_strlen=strlen(retstr);
		retstr=retstr.substring(1,read_strlen);
		//分离#----------------------------------    
        sarray=retstr.split('#'); 
		
		var  geshu=sarray.length-1;
		
        for(var v=0;v<sarray.length-1;v++)
             //alert(sarray[v]);
       //----------------------------动态增加--------------------
        for(var v=0;v<sarray.length-1;v++)
        {
		  document.form1.banji.options.add(new Option(sarray[v],sarray[v]));
        }     
		
        switch(readflag){ 
		
        case "-2": 
                infoBoard.innerHTML='<font color=red>抱歉</font>,查询失败';
				break; 
        case "1": 
                infoBoard.innerHTML='<font color=009900>有'+geshu+'个场次!</font>';
				//setTimeout(test,1000);//延时1秒
				break; 
        case "0": 
                infoBoard.innerHTML='<font color=red>no</font>'; 
				//setTimeout(test,1000);//延时1秒
       } 
	   
       return; 
} 

function openUrl(url)
 
 { 
    var objxml=new ActiveXObject("Microsoft.XMLHttp") 
    objxml.open("GET",url,false); 
    objxml.send(); 
	
    retInfo=objxml.responseText; 
    //-----------------------最重要，将%20 解码成空格，Visit W3School!") ==》Visit%20W3School%21
	retInfo=unescape(retInfo);
    if (objxml.status=="200")
	{ 
      return retInfo; 
    } 
    else
	{ 
      return "-2"; 
     } 
} 


function strlen(str) 
{
    var len = 0;
    for (var i = 0; i<str.length;i++)
	{
      if (str.charCodeAt(i)>255) len+= 2; 
	  else 
	   len ++;
    }
    return len;
}

function delete_all_select()
{
    var   theSelect=document.all.banji;   
    for(var i=theSelect.options.length-1;i>=0;i--)   
          theSelect.options.remove(i);   
}

