Dear All,
I'm a bit stuck on a problem with IHtmlDocument2 and filling in a web form.
We are trying to develop a small program to fill out an Amtrak desptach form. I came across an example of the Delphi section of About.Com which really seemed to be exactly what we required.
The article is here:
http://delphi.about.com/od/twebbrowser/a/submit_web_form.htmI won't repost the code here for sake of space!
After some initial problems (e.g there are some '.value' attributes missing in the value setting procedure), it seemed that the information I gathered from here would be exactly what we required.
I already know the field names and so it was easy to begin with to load the login screen and enter our logon details and then goto the despatch page.
I can fill all the fields on there just fine using their WebFormSetFieldValue procedure except.......
(a) I cannot seem to see how to check or uncheck a checkbox?
(b) I cannot fathom out how to set a value in a select box by it's text value? I can do it by it's itemindex but this would mean that we would need to hard code the Amtrak values into Delphi and if Amtrak change them (e.g. add a new service) which is highly likely then the wrong select value may be chosen. Is there a way to set the value field 'textually' or is there an 'indexof' type equivalent for the select element?
This is a little bit outside my day-to-day Delphi knowledge but it would be nice to be able to get this working.
Or maybe there is a better way to do this than the methods on the About website? The advantage of their method is that we can populate the HTML fields by name whereas other examples seem to access the HTML fields by an index which (again) could cause problems if Amtrak tweak their pages.
Many thanks in advance!
Trevor
Start Free Trial