Jump to content

Please help me with "_IEFormGetObjByName" !


sgn209
 Share

Go to solution Solved by mikell,

Recommended Posts

Hi everybody in AutoIT forum, have a good day.
 
I want to write a program can automatic fill IE form but I have some problem when get form name in this code:
 
</script>


<font color="#990000"><div id="ajax-address-error"></div></font><table class="enterAddressFormTable"><div id="enterAddressFormDiv">
<tr><td class="enterAddressFieldLabel" style="vertical-align:middle;"><span><label for="enterAddressFullName"><b>Full Name:&nbsp;</b></label></span></td><td><span>

<input type="text" name="enterAddressFullName" id="enterAddressFullName" class="enterAddressFormField" size="50" maxlength=50 /></span>
</td></tr><tr><td class="enterAddressFieldLabel" style="vertical-align:middle;"><span><label for="enterAddressAddressLine1"><b>Address Line1:&nbsp;</b></label></span></td><td><span>

<input type="text" name="enterAddressAddressLine1" id="enterAddressAddressLine1" class="enterAddressFormField" size="50" maxlength=60 /></span>
<br /><span class="tiny">Street address, P.O. box, company name, c/o</span></td></tr><tr><td class="enterAddressFieldLabel" style="vertical-align:middle;"><span><label for="enterAddressAddressLine2"><b>Address Line2:&nbsp;</b></label></span></td><td><span>

<input type="text" name="enterAddressAddressLine2" id="enterAddressAddressLine2" class="enterAddressFormField" size="50" maxlength=60 /></span>
<br /><span class="tiny">Apartment, suite, unit, building, floor, etc.</span></td></tr><tr><td class="enterAddressFieldLabel" style="vertical-align:middle;"><span><label for="enterAddressCity"><b>City:&nbsp;</b></label></span></td><td><span>

<input type="text" name="enterAddressCity" id="enterAddressCity" class="enterAddressFormField" size="25" maxlength=50 /></span>
</td></tr><tr><td class="enterAddressFieldLabel" style="vertical-align:middle;"><span><label for="enterAddressStateOrRegion"><b>State/Province/Region:&nbsp;</b></label></span></td><td><span>

<input type="text" name="enterAddressStateOrRegion" id="enterAddressStateOrRegion" class="enterAddressFormField" size="15" maxlength=50 /></span>
</td></tr><tr><td class="enterAddressFieldLabel" style="vertical-align:middle;"><span><label for="enterAddressPostalCode"><b>ZIP:&nbsp;</b></label></span></td><td><span>

<input type="text" name="enterAddressPostalCode" id="enterAddressPostalCode" class="enterAddressFormField" size="20" maxlength=20 /></span>
</td></tr><tr><td class="enterAddressFieldLabel" style="vertical-align:middle;"><span><label for="enterAddressCountryCode"><b>Country:&nbsp;</b></label></span></td><td><span>

This code from AMAZON with link: https://www.amazon.com/gp/css/account/address/view.html?ie=UTF8&ref_=ya_add_address&viewID=newAddress

 

Here is code i always use to fill IE form name:

 
$oForm = _IEFormGetObjByName($OIE, $FORMNAME)
$OQUERY = _IEFormElementGetObjByName($oForm, "enterAddressFullName")
_IEFormElementSetValue($OQUERY, $2FName)
$OQUERY = _IEFormElementGetObjByName($oForm, "enterAddressAddressLine1")
_IEFormElementSetValue($OQUERY, $2Add1)
$OQUERY = _IEFormElementGetObjByName($oForm, "enterAddressAddressLine2")
_IEFormElementSetValue($OQUERY, $2Add2)
$OQUERY = _IEFormElementGetObjByName($oForm, "enterAddressCity")
_IEFormElementSetValue($OQUERY, $2City)

I want to know $FORMNAME in this case or any other ways else I can do for fill the form ?

 

Thanks

Edited by sgn209
Link to comment
Share on other sites

It appears that the form doesn't have an assigned name. You can use _IEFormGetCollection to get a collection of forms and then loop through the collection until you find the desired form.

 

how to do it ? Can you show me an example ? Thanks

Link to comment
Share on other sites

 

You can also loop through the inputs

$oInputs = _IETagNameGetCollection($oIE, "input")
For $oInput In $oInputs
    If $oInput.name == "enterAddressFullName" Then $oInput.innertext = $2FName
    If $oInput.name == "enterAddressAddressLine1" Then $oInput.innertext = $2Add1
    ; etc
Next

 

Great ! Its work perfectly ! Thanks

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