无限精彩,DreamflyIT世界!

有一种执著叫坚持,有一种梦想叫超越!

导航

日语考试自动选择(五)----------完整代码

Posted on 2006-04-28 12:34  韦忠波  阅读(214)  评论(0编辑  收藏  举报

<!------------------------------------ 第一步 ---------------------------------->
<input name="txtUserID" size="18" value="210204198001011105" class="v10bk"></td>
<input type="password" name="txtPassword" size="18" value="123456" class="v10bk">
<input type="button" value="登入系统" name="btnFirst" onclick="GoFirst()" class="v10bk">

<!------------------------------------ 第二步 ---------------------------------->
<form name="form1" action="http://jlpt.etest.net.cn/bkServlet" method="post" target="main">                        <td class="v10bk">第二步 选择级别和考点</td>
级别
&nbsp;<select name="lstJb" size="1" onchange="UpdateData()" 
<option value="1">一级</option>
<option value="2">二级</option>
<option value="3" selected>三级</option>
<option value="4">四级</option>                        
</select>考点:<br>                        
<input type="button" value="大连理工大学" name="btnThird1" onclick="GoThird1()" class="v10bk" style="width:70">&nbsp;<input type="button" value="大连外国语学院" name="btnThird2" onclick="GoThird2()" class="v10bk" style="width:85"><br>
                            
<input type="button" value="辽宁师范大学" name="btnThird3" onclick="GoThird3()"class="v10bk" style="width:70">&nbsp;
<input type="button" value="辽宁大学教务处" name="btnThird4" onclick="GoThird4()"class="v10bk" style="width:85">
<input class="v10bk" type="button" value="在窗口中显示所有学校" name="btnSecond" onclick="GoSecond()"  style="width:160">    <td class="v10bk">考点编码<input name="kddm" class="v10bk"><br>
考点名称
<input name="kdmc" class="v10bk"><br>
考试等级
<input name="level" class="v10bk"><br>
级别名称
<input name="jbmc" class="v10bk">
<input type="submit" value="选择该考场" name="btnSubmit" class="v10bk" onclick="return ValidateForm()">
</form>
<!------------------------------------ 第三步 ---------------------------------->    

                        
<td colspan="2" class="v10bk">第三步:填写报名表</td>
                        
<td colspan="2" class="v10bk"><input type="button" value="填写报名表" name="btnForth" onclick="GoForth()" class="v10bk"></td>

<!------------------------------------ 第四步 ---------------------------------->    
<form name="form2" method="post">
<input type="radio" name="radAutoGo" value="1" class="v10bk" onclick="CheckTimer()">开始<input type="radio" name="radAutoGo" value="0" checked class="v10bk" onclick="CheckTimer()">结束</td>
        
            
<input type="hidden" name="lstSchool" value>
            
                    
<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">
            
                    
<td width="100%" colspan="2">
                    
<select class="v10bk" style="WIDTH:170px;" name="lstBottomlstSchool">
                    
<option value="1020102#清华大学外语系国外考试中心">清华大学外语系国外考试中心</option>
</select>


<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>
            
</td>
        
</tr>
    
</table>
</form>



<!----------------------------Javascript-------------------------------------------->
<SCRIPT LANGUAGE=javascript>
<!--
var jb,level,jbmc;

var timer1,timer2,bLogin,bCanUse,iSchool
bLogin
=false;
bCanUse
=false;
iSchool
=0;

timer1
=setInterval("OnTimer1()",20000); 
function OnTimer1(){
    
if(bCanUse){
        GoFirst();
        bLogin
=true;        
    }

}


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

    
else{
        bCanUse
=false;
    }

}

//bCanUse=false;

timer2
=setInterval("OnTimer2()",4000); 

function OnTimer2(){
    
var schoolCode="";
    
var i=-1;
    
var str1,str2;
    
//if(form2.radAutoGo[1].checked){bCanUse=false;}开始的信息
    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();
        
        }

    }

}
  
    
    
function GoFirst(){
    userName
=txtUserID.value;
    password
=txtPassword.value;    
    parent.frames[
"main"].location.href="http://jlpt.etest.net.cn/loginServlet?useridno=" + userName + "&userpwd=" + password;
    
//bCanUse=true;
}


function GoSecond(){
    UpdateData();
    parent.frames[
"main"].location.href="http://jlpt.etest.net.cn/kdinfoServlet?jb=" + jb + "&action=0";    
}



function GoThird1(){
    UpdateData();
    form1.kddm.value
="1020403";
    form1.kdmc.value
="大连理工大学外国语学院";
}


function GoThird2(){
    UpdateData();
    form1.kddm.value
="1020401";
    form1.kdmc.value
="大连外国语学院考试中心";
}


function GoThird3(){
    UpdateData();
    form1.kddm.value
="1020402";
    form1.kdmc.value
="辽宁师范大学教务处考试中心";
}


function GoThird4(){
    UpdateData();
    form1.kddm.value
="1020601";
    form1.kdmc.value
="辽宁大学教务处";
}


function GoForth(){
    parent.frames[
"main"].location.href="info.htm";
}


function ValidateForm(){
    
if((form1.kddm.value=="")||
    (form1.kdmc.value
=="")||
    (form1.level.value
=="")||
    (form1.jbmc.value
=="")){
        alert(
"请填写详细数据!");
        
return false;        
    }

    
return true;
}


function UpdateData(){
    
try{
        jb
=form1.lstJb.options[form1.lstJb.selectedIndex].value;
    }

    
catch(e){
        jb
=3;
    }

    
    
if(jb==1){
        level
=1;
        jbmc
="日语一级";
    }

    
else if(jb==2){
        level
=2;
        jbmc
="日语二级";    
    }

    
else if(jb==3){
        level
=3;
        jbmc
="日语三级";        
    }

    
else{
        level
=4;
        jbmc
="日语四级";    
    }

    form1.level.value
=level;
    form1.jbmc.value
=jbmc;    
}
  
 
UpdateData();    
//-->
</SCRIPT>