Jump to content

Recommended Posts

Posted (edited)

Hi

well how to get all names in form and get values of fileds on submit button

#include <IE.au3>
$oIE =  _IECreate ("http://localhost/demo/gm.php")
$oForm = _IEFormGetCollection ($oIE, 0)
$oText = _IEFormElementGetCollection ($oForm)
MsgBox(0, "Form Element Value", _IEFormElementGetValue ($oText))
Edited by autoitxp
Posted

Hi

well how to get all names in form and get values of fileds on submit button

By leaving the index parameter defaulted in _IEFormElementGetCollection() you got a collection object back (an array) which cannot be displayed in a MsgBox().

Try this:

#include <IE.au3>
$oIE = _IECreate("http://localhost/demo/gm.php")
$oForm = _IEFormGetCollection($oIE, 0)
$colElem = _IEFormElementGetCollection($oForm)
$iElemCnt = @extended
$sMsg = "Element values:" & @CRLF
$i = 0
For $oElem In $colElem
    $sMsg &= $i & ":  " & _IEFormElementGetValue($oElem) & @CRLF
    $i += 1
Next
MsgBox(64, $iElemCnt & " Results", $sMsg)

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Posted (edited)

Thanks !

what about submit event how can i get get value onsubmit button is it possbile like this way

#include <IE.au3>
$oIE = _IECreate("http://localhost/demo/gm.php")
_IEHeadInsertEventScript ($oIE, "document", "onsubmit", "return" &" "& _TestDataCheck())


Func _TestDataCheck()
$oForm = _IEFormGetCollection($oIE, 0)
$colElem = _IEFormElementGetCollection($oForm)
$iElemCnt = @extended
$sMsg = "Element values:" & @CRLF
$i = 0
For $oElem In $colElem
    $sMsg &= $i & ":  " & _IEFormElementGetValue($oElem) & @CRLF
    $i += 1
Next
MsgBox(64, $iElemCnt & " Results", $sMsg)
EndFunc
Edited by autoitxp
Posted

Thanks !

what about submit event how can i get get value onsubmit button is it possbile like this way

#include <IE.au3>
$oIE = _IECreate("http://localhost/demo/gm.php")
_IEHeadInsertEventScript ($oIE, "document", "onsubmit", "return" &" "& TestDataCheck())


Func _TestDataCheck()
$oForm = _IEFormGetCollection($oIE, 0)
$colElem = _IEFormElementGetCollection($oForm)
$iElemCnt = @extended
$sMsg = "Element values:" & @CRLF
$i = 0
For $oElem In $colElem
    $sMsg &= $i & ":  " & _IEFormElementGetValue($oElem) & @CRLF
    $i += 1
Next
MsgBox(64, $iElemCnt & " Results", $sMsg)
EndFunc
No, I think the code executed in the last parameter of _IEHeadInsertEventScript() has to be java script that will be executed in the browser, not external AutoIt code or an AutoIt function call.

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Posted (edited)

Hi

hey if html body have more then 1 form then how to get values of all forms in page like im trying this but not successfull :)

#include <IE.au3>
$oIE = _IECreate("http://localhost/demo/gm.php")
$oForms = _IEFormGetCollection($oIE)
$iNumForms = @extended
For $i = 0 to $iNumForms - 1
$oForm = _IEFormGetCollection ($oIE, $i)
$colElem =   _IEFormElementGetCollection($oForm)

Next

$iElemCnt = @extended
$sMsg = "Element values:" & @CRLF
$i = 0
For $oElem In $colElem
    $sMsg &= $i & ":  " & _IEFormElementGetValue($oElem) & @CRLF
    $i += 1
Next
MsgBox(64, $iElemCnt & " Results", $sMsg)
Edited by autoitxp
Posted

I have this loop i made long time ago used to check Form # and Element #, play with it and I believe you will get what you want

#include<IE.au3>
$thread="http://virusscan.jotti.org/"
$Time=5000

_ForumReply($thread,$Time)

Func _ForumReply($ThreadLink,$oTimeout)
    Local $oIE,$oForm,$oQuery,$o_Query
    _IEErrorHandlerRegister()
    _IELoadWaitTimeout($oTimeout)
    $oIE=_IECreate($ThreadLink,0,1,1)
    MsgBox(64,"Warning","Input text into element and click ok to continue")
    $oForm = _IEFormGetCollection ($oIE)
    $iNumForm=@extended
    For $i=0 to $iNumForm-1
        $oForm = _IEFormGetCollection ($oIE, $i)
        $oQuery = _IEFormElementGetCollection ($oForm)
        $iNumElement=@extended
        For $n=0 to $iNumElement-1
            $o_Query=_IEFormElementGetCollection($oForm,$n)
            If String(_IEFormElementGetValue($o_Query))="Input" Then
                MsgBox(64,"Form: "&$i,"Element: "&$n)
                ExitLoop
            EndIf
        Next
    Next
EndFunc
Posted

Hi

hey if html body have more then 1 form then how to get values of all forms in page like im trying this but not successfull ^_^

You need to nest the loop for the elements inside the loop for the forms:

#include <IE.au3>
$oIE = _IECreate("http://localhost/demo/gm.php")

$colForms = _IEFormGetCollection($oIE)
$iFormCnt = @extended
$iForm = 0
$sMsg = "Element values:" & @CRLF
For $oForm In $colForms
    $colElem = _IEFormElementGetCollection($oForm)
    $iElemCnt = @extended
    
    $iElem = 0
    For $oElem In $colElem
        $sMsg &= "Form " & $iForm & ": Elem " & $iElem & ":  " & _IEFormElementGetValue($oElem) & @CRLF
        $iElem += 1
    Next
    
    $iForm += 1
Next

MsgBox(64, $iElemCnt & " Results", $sMsg)

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

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
×
×
  • Create New...