Jump to content

How to get name and value in form?


ThanhBT
 Share

Recommended Posts

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

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

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
Link to comment
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:

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...