日语考试自动进入系列(四)

第四步
<form name="form2" method="post">

<input type="hidden" name="lstSchool" value>

<input type="radio" name="radAutoGo" value="1" class="v10bk" onclick="CheckTimer()">开始<input type="radio" name="radAutoGo" value="0" checked class="v10bk" onclick="CheckTimer()">结束

<select width="100%" class="v10bk" style="WIDTH:165; HEIGHT:110" multiple size="8" name="lstToplstSchool">
     <option value="1020401#大连外国语学院考试中心">大连外国语学院考试中心</option>
     <option value="1020402#辽宁师范大学教务处考试中心">辽宁师范大学教务处考试中心</option>
     <option value="1020403#大连理工大学外国语学院">大连理工大学外国语学院</option>
     </select>

     <input type="button" class="v10bk" onclick="ClickMove_lstSchool('Up')" value=" /\ " name="btnUP_lstSchool">
<input type="button" class="v10bk" onclick="ClickMove_lstSchool('Down')" value=" \/ " name="btnDown_lstSchool">
<input type="button" class="v10bk" onclick="return btnLeft_lstSchool_onclick()" value="Add" name="btnLeftlstSchool">
<input type="button" class="v10bk" onclick="return btnRight_lstSchool_onclick()" value="Remove" name="btnRightlstSchool">

     <select class="v10bk" style="WIDTH:170px;" name="lstBottomlstSchool">
     <option value="1020102#清华大学外语系国外考试中心">清华大学外语系国外考试中心</option>
     <option value="1020103#北京语言大学国外考试中心">北京语言大学国外考试中心</option>
     <option value="1020104#北京师范大学国外考试中心">北京师范大学国外考试中心</option>
     <option value="1020105#北京第二外国语学院日语系">北京第二外国语学院日语系</option>
     <option value="1020201#上海外国语大学海外考试中心">上海外国语大学海外考试中心</option>
</select >

function CheckTimer(){
    
if(form2.radAutoGo[0].checked){
        GoFirst();
        iSchool
=0;
        bCanUse
=true;
    }

    
else{
        bCanUse
=false;
    }

}
function ClickMove_lstSchool(strDirection){     
     Select2_ClickUpDown(form2.lstToplstSchool,strDirection);
     lstSchoolUpdate();
 }
 function btnRight_lstSchool_onclick() {
     Select2_ClickBottom(form2.lstToplstSchool,form2.lstBottomlstSchool);
     lstSchoolUpdate();
 }
<script language="javascript">
 
function ClickMove_lstSchool(strDirection){      
     Select2_ClickUpDown(form2.lstToplstSchool,strDirection);
     lstSchoolUpdate();
 }

 
function btnLeft_lstSchool_onclick() {       
     Select2_ClickTop(form2.lstToplstSchool,form2.lstBottomlstSchool);
     lstSchoolUpdate();
 }

 
function btnRight_lstSchool_onclick() {
     Select2_ClickBottom(form2.lstToplstSchool,form2.lstBottomlstSchool);
     lstSchoolUpdate();
 }
   
 
function lstSchoolUpdate(){
    form2.lstSchool.value
=Select2_GetValue(form2.lstToplstSchool);  
 }

 lstSchoolUpdate();  
// Set Default Value
 
 
function Select2_ClickUpDown(objSelect,strDirection){        
    
//Make order for select 
    var iCurrentIndex;
    
var strValue;
    
var strText;
    
    iCurrentIndex
=objSelect.selectedIndex;
    
if(iCurrentIndex==-1)return;
    
    strValue
=objSelect.options(iCurrentIndex).value;
    strText
=objSelect.options(iCurrentIndex).text;
    
if(strDirection=="Up"){
        
if(iCurrentIndex-1>=0){
            objSelect.options(iCurrentIndex).value
=objSelect.options(iCurrentIndex-1).value;
            objSelect.options(iCurrentIndex).text
=objSelect.options(iCurrentIndex-1).text;
            objSelect.options(iCurrentIndex
-1).value=strValue;
            objSelect.options(iCurrentIndex
-1).text=strText;
            objSelect.selectedIndex
=iCurrentIndex-1;
        }

    }

    
else if(strDirection=="Down"){
        
if(iCurrentIndex+2<=objSelect.length){
            objSelect.options(iCurrentIndex).value
=objSelect.options(iCurrentIndex+1).value;
            objSelect.options(iCurrentIndex).text
=objSelect.options(iCurrentIndex+1).text;
            objSelect.options(iCurrentIndex
+1).value=strValue;
            objSelect.options(iCurrentIndex
+1).text=strText;
            objSelect.selectedIndex
=iCurrentIndex+1;
        }

    }
    
}


function Select2_ClickLeft(objLeftSelect,objRightSelect){        
    
//Move options from right select to left select
    var i=0;
    
while(i<objRightSelect.options.length){
       
if(objRightSelect.options[i].selected){
          objLeftSelect.add(
new Option(objRightSelect.options[i].text,objRightSelect.options[i].value));
          objRightSelect.remove(i);
          i
=0;
       }

       
else{
          i
++;               
       }

    }

}


function Select2_ClickRight(objLeftSelect,objRightSelect){
    
//Move options from left select to right select
    var i=0;
    
while(i<objLeftSelect.options.length) {
       
if(objLeftSelect.options[i].selected){
          objRightSelect.add(
new Option(objLeftSelect.options[i].text,objLeftSelect.options[i].value));
          objLeftSelect.remove(i);
          i
=0;
       }

       
else{
          i
++;               
       }

    }
    
}


 
function Select2_ClickTop(objTopSelect,objBottomSelect){  
     
//Move options from bottom select to top select     
     var i=0;
     i
=objBottomSelect.selectedIndex;
     
if((i!=-1)&&(objBottomSelect.options[i].text!="")){
          objTopSelect.add(
new Option(objBottomSelect.options[i].text,objBottomSelect.options[i].value));
          objBottomSelect.remove(i);
          
if(i>-1){
             objBottomSelect.selectedIndex
=i-1;
          }

     }

 }

 
 
function Select2_ClickBottom(objTopSelect,objBottomSelect) {
     
//Move options from top select to bottom select      
     var lastRemove=-1;
     
var i=0;
     
while(i<objTopSelect.options.length) {
        
if(objTopSelect.options[i].selected){
           objBottomSelect.add(
new Option(objTopSelect.options[i].text,objTopSelect.options[i].value));
           objTopSelect.remove(i);
           lastRemove
=i;
           i
=0;
        }

        
else{
           i
++;
        }

     }
   
     
try{
         
if(lastRemove>-1){
             objTopSelect.selectedIndex
=lastRemove-1;
         }

     }
catch(e){}
 }
 

function Select2_SetValue(objLeftSelect,objRightSelect,str){
    
var i=0,iBegin,iEnd,iOptionValue,strOptionValue,strTempText,strTempValue;
    
//Move options from right select 
    while(i<objRightSelect.options.length) {
        
if(str.indexOf("#"+objRightSelect.options[i].value+"#")!=-1){
            objLeftSelect.add(
new Option(objRightSelect.options[i].text,objRightSelect.options[i].value));
            objRightSelect.remove(i);
            i
=0;
        }

        
else{
            i
++;
        }

    }

    
    
//Make order for left select
    iOptionValue=0;
    
while(str!="" && str!="#"){           
           iBegin
=str.indexOf("#");
           
if(iBegin==-1)
               
break;    
           iEnd
=str.indexOf("#",iBegin+1);
           
if(iEnd==-1)
               
break;
           strOptionValue
="#"+str.substring(iBegin+1,iEnd)+"#";
           str
=str.substring(iEnd,str.length);
           
for(i=iOptionValue;i<objLeftSelect.options.length;i++{
                
if(strOptionValue.indexOf("#"+objLeftSelect.options[i].value+"#")!=-1){                       
                    strTempText 
=objLeftSelect.options[iOptionValue].text;
                    strTempValue
=objLeftSelect.options[iOptionValue].value;
                    objLeftSelect.options[iOptionValue].text  
= objLeftSelect.options[i].text ;
                    objLeftSelect.options[iOptionValue].value 
= objLeftSelect.options[i].value;
                    objLeftSelect.options[i].text  
= strTempText ;
                    objLeftSelect.options[i].value 
= strTempValue;
                    
break;
                   }

           }

           iOptionValue
++;
    }

    lstSelectedField_onchange();
}


function Select2_GetValue(objSelect){
    
var strValue="#";
    
for(i=0;i<objSelect.options.length;i++{
         strValue
+=objSelect.options[i].value;
         strValue
+="#";
    }

    
return strValue;
}

 
     
</script>


//结束时则调用GoFirst();使它处于未选择考场状态
function CheckTimer(){
 if(form2.radAutoGo[0].checked){
  GoFirst();
  iSchool=0;
  bCanUse=true;
           }
 else{
  bCanUse=false;
      }
}

//设置时间为4秒,不断提交所选的考场
timer2=setInterval("OnTimer2()",4000);
function OnTimer2(){
 var schoolCode="";
 var i=-1;
 var str1,str2;
 
 if(bCanUse){
  if(bLogin){ 
   try{   
    if(iSchool>=form2.lstToplstSchool.options.length)    
     iSchool=0;
    schoolCode=form2.lstToplstSchool.options[iSchool].value;
    if(schoolCode!=""){
     i=schoolCode.indexOf("#");
     str1=schoolCode.substring(0,i);
     str2=schoolCode.substring(i+1,schoolCode.length);
     form1.kddm.value=str1;
     form1.kdmc.value=str2;
    }
      
    iSchool=iSchool+1;
    if(iSchool>=form2.lstToplstSchool.options.length)    
     iSchool=0;
   }
   catch(e){} 
   form1.submit();//不断提交预定
  
  }
 }

原文地址:https://www.cnblogs.com/Dreamfly/p/387392.html