Jump to content

[Solved]IEFormElementGetCollection input text


Recommended Posts

Local $oIE=_IEAttach("卡務系統","text")
_IELoadWait($oIE)
Local $oForms = _IEFormGetCollection($oIE,0)
Local $oElements = _IEFormElementGetCollection ($oForms, 1)
_IEFormElementSetValue($oElements, "0031896")


$oElements = _IEFormElementGetCollection ($oForms)
MsgBox($MB_SYSTEMMODAL, "Element Info", "There are " & @extended & " Element(s) on this page")
$oMsg = " "
For $oElement In $oElements
   $oMsg &= $oElement.name & "        " & $oElement.type & @CRLF

Next
MsgBox($MB_SYSTEMMODAL, "Element Info", "Name:" & "       " & "Type:" & @CRLF & $oMsg)

I have some problem with IEFormElementGetCollection, 

the page I attach has 1 form, 7 elements and no frame.

image.png.b68f56f9a4ad04f5d967883ec1be67e8.png

UserID and CHK are what I want to input text, but my code didn't show error and it just do nothing.....

example of IEFormElementGetCollection which type and search at google can run successfully.

here is html:

<html>
<head>
<title>差勤卡務系統登錄畫面</title>
<meta http-equiv="Content-Type" content="text/html; charset=big5">


<script language="JavaScript" type="text/JavaScript">
<!--
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
</script>
</head>

<script type="text/javascript">

   var aliveIP = "106";
   function getTime(){
            var currentTime = new Date();
            return currentTime.getTime();
        }
        
   function createAJAX() {
      
            var http_request ;
            
            if (window.XMLHttpRequest) { // Mozilla, Safari,...
                http_request = new XMLHttpRequest();
                //http_request.overrideMimeType('text/xml');                   
                return http_request;
            }else if (window.ActiveXObject) { // IE
               try {
                 return new ActiveXObject("Msxml2.XMLHTTP");
               }catch (e) {
                  try{
                     return new ActiveXObject("Microsoft.XMLHTTP");
                  } catch (e) {}
               }
            }

            if (!http_request) {
                alert('Giving up :( Cannot create an XMLHTTP instance');
                return false;
            }                   
   }                    
       
   function serverIsLive(serverip) {                                        
            
            var uri = 'checkAPLiveService.jsp?ip='+serverip+'&process='+ getTime();                                  
//alert(uri); 
            ajax = createAJAX() ;
               
            if (!ajax) {
              alert ('使用不相容 XMLHttpRequest 的瀏覽器');         
            }          
            ajax.onreadystatechange = onServerLive;   
            ajax.open ("GET", uri, true);   
            ajax.send (null);                    
        }
        
    function onServerLive(){
    
        if (ajax.readyState == 4) {
           if (ajax.status == 200) {                                            
                document.getElementById('aliveIP').value = ajax.responseText;  
                //alert(' ip ' + document.getElementById('aliveIP').value);       
           }
            
        }else if (ajax.readyState == 0) {              
        }else if (ajax.readyState == 1) {              
        }else if (ajax.readyState == 2) {              
        }else if (ajax.readyState == 3) {
              
        }                
    }    
        
    //----------------------------------------------------------------------------        
    var cnt = '1'

    function forward(){
       var myform = document.getElementById('myForm');
       myform.action="hrcardlogin.jsp"
       document.getElementById('UserID').value = '';
       document.getElementById('CHK').value = '';       
       
              
       if (cnt == 0 ){
          document.getElementById('forwardcnt').value ="1";
          document.getElementById('myForm').submit();
       }else if (cnt > 0){

          
          
                 document.getElementById('loginStatus').innerHTML ="" ;  

            
       }   
   }
   
   function get_random()
   {      
      // 0 ~ 9 
      var ranNum= Math.floor(Math.random()*9);
      return ranNum;
   }


   function toHr(){   
       //alert("tohr");
       
       var id = document.getElementById('UserID').value;

       /*   2009/12/24  add new code by scott */
       /* due to dispatcher users to other servers */
       var ip = "106";
       var vip = "645366,007662,764285,007936";
       
       if (vip.indexOf(id) >= 0 ){
          ip="106";       
          
       }else{
         if (parseInt(id.substr(id.length-3,1))== 0)  
           ip="106";
         else if (parseInt(id.substr(id.length-3,1)) <= 3 )  
           ip="106";  
         else if (parseInt(id.substr(id.length-3,1)) <= 6 )  
           ip="106";     
         else if (parseInt(id.substr(id.length-3,1)) <= 9 )  
           ip="106";     
       }
        
 -       
       serverIsLive(ip);                                    
       //setTimeout("postToHR();",1000);
       postToHR();
       

                    
   }

    
    function checkVal( str ) {
        var regExp = /^[a-zA-Z]+$/;
        if (regExp.test(str))  return true;
        else return false;
    }

   function postToHR(){
       var id = document.getElementById('UserID').value;

    if ((id.length >= 7) && id.substr(0,1) == '0'){
       if (! checkVal(id.slice(-1))){ 
        id=id.substr(1);
        document.getElementById('UserID').value= id;
       }
    }  

       var ip = document.getElementById('aliveIP').value.replace(/^\s+|\s+$/g,"");  
//alert("pthr 1"); 
       if (checkmember()){
//alert("pthr 2");        
//document.getElementById('myForm').action = "http://192.168.100."+ip+":809"+id.substr(id.length-2,1)+"/plmnew/plugins/app/login/ssoKey_109.jsp";         
        document.getElementById('myForm').action = "http://lcms-slb.tra.gov.tw" +"/plmnew/plugins/app/login/ssoKey_109.jsp";          //:809"+id.substr(id.length-2,1)
          document.getElementById('WebID').value= "plmnew";     
         //alert('連線至差勤系統:Server-'+document.getElementById('myForm').action);             
          document.getElementById('myForm').submit();               
       }                       
   }
   
   function toCard(){
       //alert("toCard");
       if (checkmember()){         
          //document.getElementById('myForm').action = "http://192.168.100.101:8080/eSecureRCMS/Logon.aspx";
          document.getElementById('myForm').action = "http://lcmscs.tra.gov.tw";  //"http://192.168.100.102";
          document.getElementById('WebID').value= "eSecureRCMS";        
                
          document.getElementById('myForm').submit();        
        }             
   }
   //20090603 ray add new function------------------------------------------
   function toQA(){
        //alert("toQA");
        document.getElementById('myForm').action = "http://lcmsdb.tra.gov.tw:8080" ; 
        document.getElementById('WebID').value= "traQA";
        document.getElementById('myForm').submit(); 
   }
   //20090911 ray add new function------------------------------------------
   function traSurvey(){
        //alert("toQA");
        document.getElementById('myForm').action = "http://lcmsdb.tra.gov.tw8080/traSurvey/";
        document.getElementById('WebID').value= "traSurvey";
        document.getElementById('myForm').submit(); 
   }
   //-----------------------------------------------------------------------
   function checkmember(){
       
       if(document.getElementById('UserID').value == "" || document.getElementById('CHK').value==""){
          alert("請輸入帳號和密碼 !");
          return false;
       }else{
          id = document.getElementById('UserID').value; 
          if (id.toUpperCase().substring(0,2) == "TR"){
             document.getElementById('UserID').value = id.substring(2);
          }
          
          return true;    
       }      
   }
   function txtOnchang(){
        isMd5="0";
        document.getElementById('flag').value= "0";//jas 20141021 add
   }

   function detectBrowser(){ //jas 20150122 add
        var Sys = {};
        var ua = navigator.userAgent.toLowerCase();



        if (!!navigator.userAgent.match(/Trident\/7\./))
        {
                
                var isIE11 = true;
        }
        
        else if (window.ActiveXObject){
                Sys.ie = ua.match(/msie ([\d.]+)/)[1];  //正則匹配 "msie 8.0"
        }

        else if(ua.indexOf("firefox")!=-1){
                Sys.firefox = ua.match(/firefox\/([\d.]+)/)[1]; 
        }
        
        else if (window.MessageEvent && !document.getBoxObjectFor){
                Sys.chrome = ua.match(/chrome\/([\d.]+)/)[1]; 
        }
        
        else if (window.opera){
                Sys.opera = ua.match(/opera.([\d.]+)/)[1];
        }
        
        else if (window.openDatabase){
                Sys.safari = ua.match(/version\/([\d.]+)/)[1];
        }
        
        if(Sys.ie) document.write('瀏覽器為 IE: '+Sys.ie);
        if(isIE11) document.write('瀏覽器為 IE: 11');
        if(Sys.firefox) document.write('瀏覽器為 Firefox: '+Sys.firefox);
        if(Sys.chrome) document.write('瀏覽器為 Chrome: '+Sys.chrome);
        if(Sys.opera) document.write('瀏覽器為 Opera: '+Sys.opera);
        if(Sys.safari) document.write('瀏覽器為 Safari: '+Sys.safari);

        
    }
      //<body 112 onload="forward()">
</script>


<body 112 onload="forward()">

<form id="myForm" action="" method="post">
      <input name="forwardcnt" type="hidden" id="forwardcnt" value="0">
            <table border="0" width="1003" id="table2" height="585" background="image/z1.jpg" bgcolor="#FFFFFF">
                <tr>
                  <td height="85"> </td>
                  <td colspan="2"> </td>
              </tr>
                <tr>
                  <td width="105" height="350"> </td>
                  <td colspan="2">
                    <div align="center">
                        <table border="0" id="table3" height="306" cellspacing="0" cellpadding="0">
                            <tr>
                                <td height="47" colspan="2">
                                    <div align="left">                                </div></td>
                            </tr>
                            <tr>
                                <td height="30" colspan="2"><img border="0" src="image/6.jpg" width="31" height="31" vspace="8"><img border="0" src="image/3.gif">
                                </td>
                            </tr>
                            <tr>
                                <td height="163" colspan="2">
                                <table border="0" width="622" id="table6" height="127">
                                    <tr>
                                        <td width="29" rowspan="3"> </td>
                                        <td width="156" rowspan="3" height="127" background="image/x.gif">

<table cellpadding="0" cellspacing="0" border="0" id="table9" width="155"><tr><td>
 </td></tr><tr>
        <td width="155" height="62" background="image/7.gif" align="center">

<table cellpadding="0" cellspacing="0" class="fontb2" id="table10"><tr>
    <td height="16">
    </td></tr><tr><td><input name="UserID" type="text" id="UserID" style="height: 20px; width: 120px;" value="" class="noteip" 
 >
</td>
    </tr><tr>
        <td height="18">
        </td></tr><tr><td><input name="CHK" type="password" id="CHK" style="height: 20px; width: 120px;" value="" onchange="txtOnchang()" >
</td>
        </tr><tr><td>
</td></tr></table>

</td></tr></table>
                                        </td>
                                        <td width="20" rowspan="3"> </td>
                                        <td width="399" height="32"> <div class="style4" id="loginStatus"></div></td>
                                    </tr>
                                    <tr>
                                        <td width="399" height="81">
                                        <a href="#" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('img5','','image/22.gif',0)"><img src="image/11.gif" name="img5" width="239" height="61" border="0" onClick="toHr()"></a></td>
                                    </tr>
                                    
                                    <tr>
                                        <td width="399" height="6"></td>
                                    </tr>
                              </table>                            </td>
                            </tr>
                            <tr>
                                <td height="61" width="220" > 
                                <input type="hidden" name="WebID" id="WebID" value="">
                                <input type="hidden" name="aliveIP" id="aliveIP" value="106">  
                                <input type="hidden" name="flag" id="flag" value="0">                             </td>
                                <td height="61" width="414">                                <a href="#" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('img6','','image/44.gif',0)"><img src="image/33.gif" name="img6" width="239" height="61" border="0" onClick="toCard()"></a></td>
                            </tr>
                            <tr>
                              <td height="2" colspan="2">
                                    <a href="#" border="0" onClick="toQA()">Q&A</a>
                                      
                                
                                    <span class="fontb2"><br>無法以(EIP)系統直接登入者.請於差勤系統登入網頁,以舊密碼登入
                                    <br>然後在差勤系統內個人資料->變更個人密碼後(與EIP相同), 再重新登入系統。   <font color="#FF0000" size="2" face="細明體">差勤卡務客服電話:02-4541 </span>
                              </td>
                              
                              </tr>
                      </table>
                      
                    </div></td>
                </tr>
                <tr>
                  <td> </td>
                  <td width="377"><span class="fontb2">卡務管理 :<br>
使用對象:系統管理員、人事人員。<br>
功能概要: IC 卡製卡、臨時卡借出、刷卡資料查詢、卡鐘及通行設定。<br>

</span>
</td>
                  <td width="507"><span class="fontb2">差勤簽核 :<br>
使用對象:所有人員。<br>
功能概要:</span></td>
              </tr>
  </table>
        
<br>
          </span>
<p> </p>
<input type="submit" name="a" id="ss" value="" onclick="toHr()" style="position:relative;left:-200px" >
</form>
</body>
</html>


<script language="JavaScript" type="text/JavaScript">
    if (cnt == 0 ){ //密碼錯誤時的判別
        x =document.getElementById("myForm"); x.style.display = 'none';
    }
        
    detectBrowser();
</script>

 

Edited by yffulf
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...