Jump to content
Sign in to follow this  
sgn209

Please help me with "_IEFormGetObjByName" !

Recommended Posts

sgn209
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

Share this post


Link to post
Share on other sites
sgn209

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

Share this post


Link to post
Share on other sites
mikell

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
  • Like 1

Share this post


Link to post
Share on other sites
sgn209

 

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

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  

×