Sign in to follow this  
Followers 0
ThanhBT

How to get name and value in form?

7 posts in this topic

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.

Share this post


Link to post
Share on other sites



You could try _IETagNameGetCollection(), loop through each, compare the name of each against a regex and if it matches you've got your reference.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

OOps did I say _IETagNameAllGetCollection? I meant _IEFormElementGetCollection(). Sorry I don't know what I was/still am thinking.

Share this post


Link to post
Share on other sites

remove this line:MsgBox(0, "Name input ID 2", $oElement[2].name)

$oElement is not an Array.

$oElements is not an Array too.

Share this post


Link to post
Share on other sites

#6 ·  Posted (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 by MrMitchell

Share this post


Link to post
Share on other sites

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 :graduated:

Share this post


Link to post
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
Sign in to follow this  
Followers 0