Is it possible to use IE_FormFill> and the Tag of an obje

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
iggytomcarr
Newbie
Posts: 6
Joined: Fri Jan 14, 2011 10:35 am
Location: Birmingham, UK
Contact:

Is it possible to use IE_FormFill> and the Tag of an obje

Post by iggytomcarr » Fri Jan 14, 2011 11:36 am

Hi All,

Sorry if this is a daft question, but i am a new to macro scripter!

I have successful written a script whereby i can extract the price of a product from a supplier's website.

Let>SPAN15_SIZE=4098
IE_ExtractTag>%IE[1]%,,SPAN,15,0,SPAN15,r
MidStr>r_6,1,r,SPAN15

What i am now trying to do is sort of reverse this type of operation and i am trying to use the IE_FormFill command to do this.

The problem i am having is that if i use the "price" identifier IE_FormFill only fills out the first price box on the page (and i need to fill around 10 boxes with the same updated price).

I was wondering if there was a way that i can specify the 'tag' of the boxes i need to update to IE_FormFill?

I would have thought this was possible but I don’t know if I’ve been staring at my computer screen too long now! I just cant seem to work out how to do it.

Any help would be greatly appreciated!!

Thanks

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Fri Jan 14, 2011 12:07 pm

Hi,

At the moment I'm afraid IE_FormFill only supports the Name or ID attributes as identifiers.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

iggytomcarr
Newbie
Posts: 6
Joined: Fri Jan 14, 2011 10:35 am
Location: Birmingham, UK
Contact:

Post by iggytomcarr » Fri Jan 14, 2011 12:13 pm

Hi Marcus

Thanks for your very quick reply.

Are you able to show me an code example of how to use the ID attribute with IE_FormFill?

Thanks for your time!

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Fri Jan 14, 2011 12:18 pm

Just specify the ID instead of the Name.

Here's the help topic with the appropriate section bolded.

FormFill
Top Previous Next

Function FormFill(IEInst:integer; frame, form, fieldname, fieldvalue, event:pchar):integer; stdcall;


Fills a form field.

IEInst: The identifier of the web browser instance to use.

frame: the name of the frame containing the form field object

form: the name of the form (can be blank if the form has no name).

fieldname: the name of the field to fill. If the field has no name but has an ID attribute, the ID attributed can be specified instead.

fieldvalue: the value to set the field value to.

event: optional parameter that can take one of the following values:

submit: forces the form to submit.

onchange: triggers the field's onchange handler if it has one.



If the field is a SELECT object it is possible to select an item based on it's index, rather than actual value, by specifying fieldvalue as:

#INDEX#:n where n is the zero based index of the item. To select all items in a multi-select SELECT object use #INDEX#:ALL



Returns the number of fields that matched the specified values if successful, 0 if unsuccessful.





Macro Scheduler Usage



Import Method (Requires Macro Scheduler 9.2)



IE_FormFill>IE0,,main_form,firstname,Fred,0,r



LibFunc Method



LibFunc>hIE,FormFill,r,IE0,,main_form,firstname,Fred,0
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

iggytomcarr
Newbie
Posts: 6
Joined: Fri Jan 14, 2011 10:35 am
Location: Birmingham, UK
Contact:

Post by iggytomcarr » Fri Jan 14, 2011 12:29 pm

Hi Marcus,

Thanks for that information.

So instead of using the name of the field (which in this case is 'price'):

Code: Select all

Let>FrameName={""}
Let>FormName={""}
Let>FieldName={"price"}   //Currently the code looks for a field called 'price'
Let>FieldValue={"%Todays_Cost_Conv%"}
IE_FormFill>%IE[1]%,str:FrameName,str:FormName,str:FieldName,str:FieldValue,0,r

So using the ID attribute the code would look something like this?
(using the webrecorder - it tells me the TAG is 'INPUT 2077')

Code: Select all


Let>FrameName={""}
Let>FormName={""}
Let>FieldName={"INPUT2077"}  //Now code is looking for object INPUT2077???
Let>FieldValue={"%Todays_Cost_Conv%"}
IE_FormFill>%IE[1]%,str:FrameName,str:FormName,str:FieldName,str:FieldValue,0,r

Would this be correct??? Or is the ID completely different to the TAG web recorder is telling me this object's name is?

Thanks for your time!

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Fri Jan 14, 2011 1:33 pm

No, that is not the ID.

Note that the help says that if the element does NOT have a Name then an ID can be used instead. So Name takes precedence. If it DOES have a Name entering an ID will not help.

BUt if you want the ID look at the souce of the page and you may see something like:

Code: Select all

<input NAME="username" ID="username" ....
The ID is the bit after ID=
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

iggytomcarr
Newbie
Posts: 6
Joined: Fri Jan 14, 2011 10:35 am
Location: Birmingham, UK
Contact:

Post by iggytomcarr » Fri Jan 14, 2011 1:54 pm

Hi Marcus,

Right I understand! - the ID comes from the HTML source itself!

If there is more than one object with an ID of 'price' on a page - is there any way to cycle through them and to fill all of them???

Thanks Again!

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Fri Jan 14, 2011 2:20 pm

No, 'fraid not.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts