ThanhBT Posted September 15, 2011 Share Posted September 15, 2011 I have some html code same that<form action="data.aspx" target="Data" name="Data"> <input type="hidden" name="Game" value="0" /> <input type="hidden" name="OrderBy" value="0" /> <input type="hidden" name="Type" value="4" /> <input type="hidden" name="Disp" value="0" /> <input type="hidden" name="a153265497" value="b153265738" /> </form> i want to get name and value of the last input hidden, because name and value is random with type<input type="hidden" name="a?????????" value="b?????????" /> Anyone can help me, thanks a lot.Sorry for my english. Link to comment Share on other sites More sharing options...
MrMitchell Posted September 15, 2011 Share Posted September 15, 2011 You could try _IETagNameGetCollection(), loop through each, compare the name of each against a regex and if it matches you've got your reference. Link to comment Share on other sites More sharing options...
ThanhBT Posted September 15, 2011 Author Share Posted September 15, 2011 You could try _IETagNameGetCollection(), loop through each, compare the name of each against a regex and if it matches you've got your reference. Thanks for your reply, i already used _IETagNameGetCollection() and _IETagNameAllGetCollection() but don't know to use return data, array not work.$oElements = _IETagNameAllGetCollection ($oForms) For $oElement In $oElements if $oElement.tagname = "input" then msgbox(0, $oElement.name, $oElement.value) Next MsgBox(0, "Name input ID 2", $oElement[2].name) Error return: Error parsing function call.: MsgBox(0, "Name input ID 2", $oElement[2].name) MsgBox(0, "Name input ID 2", $oElement^ ERROR Link to comment Share on other sites More sharing options...
MrMitchell Posted September 15, 2011 Share Posted September 15, 2011 OOps did I say _IETagNameAllGetCollection? I meant _IEFormElementGetCollection(). Sorry I don't know what I was/still am thinking. Link to comment Share on other sites More sharing options...
Juvigy Posted September 16, 2011 Share Posted September 16, 2011 remove this line:MsgBox(0, "Name input ID 2", $oElement[2].name) $oElement is not an Array. $oElements is not an Array too. Link to comment Share on other sites More sharing options...
MrMitchell Posted September 16, 2011 Share Posted September 16, 2011 (edited) Here try like this: $oElements = _IETagNameAllGetCollection ($oForms) For $oElement In $oElements ;Go thru all the elements in the collection If $oElement.tagname = "input" then ;If the next tag is an "input" then check it further If StringRegExp($oElement.name, "a\d+") Then ExitLoop ;If the name matches regex then exit the loop leaving $oElement intact so you can continue to use it... EndIf Next $elementName = $oElement.name $elementValue = $oElement.value MsgBox(0, $elementName, $elementValue) Edited September 16, 2011 by MrMitchell Link to comment Share on other sites More sharing options...
ThanhBT Posted September 17, 2011 Author Share Posted September 17, 2011 Here try like this: $oElements = _IETagNameAllGetCollection ($oForms) For $oElement In $oElements ;Go thru all the elements in the collection If $oElement.tagname = "input" then ;If the next tag is an "input" then check it further If StringRegExp($oElement.name, "a\d+") Then ExitLoop ;If the name matches regex then exit the loop leaving $oElement intact so you can continue to use it... EndIf Next $elementName = $oElement.name $elementValue = $oElement.value MsgBox(0, $elementName, $elementValue) Thanks man, that correct i try. Thanks for your help Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now