Triggering HTML Events with LotusScript

Hello,I’m working on a project that automates the submission of data grabbed from a Notes database and copied into ‘select’ boxes on an external website. I’m using LotusScript to create the script and the external website is written in plain old HTML with javascript functions called when events are triggered.

I was wondering if it is possible to simulate events occurring on a webpage. For instance, one of the fields on the website has a javascript method that is called when the ‘select’ box’s selected ‘option’ is changed. The method populates the options of a different ‘select’ box, that I need to select an ‘option’ from. (ie. the first ‘select’ box contains options ‘cat’ and ‘dog’, when ‘cat’ is selected the second ‘select’ box has the options ‘jaguar’ and ‘lion’ available, but when the ‘dog’ option is selected the second ‘select’ box has options ‘wolf’ and ‘coyote’.)

Currently, I’m using LotusScript to set the ‘.selected’ attribute of each ‘select’ box’s ‘option’ that I want to ‘true’. This, however, does not trigger the ‘onChange’ event that calls the javascript method I need called to populate the options in the next ‘select’ box.

I was wondering if there was a way to call the javascript methods from LotusScript, or at least simulate an event like ‘onChange’ happening. It seems like it would be as simple as changing an attribute called “changed” or something to ‘true’, but I can’t figure out how to do it. Any ideas?

I’m also looking for a way to simulate a button on the website being pressed so that the ‘onSubmit’ attribute’s javascript method is called.

Any help would be appreciated. Thanks.

The website ‘select’ box with the event that I need to trigger:

My code for accessing the website’s objects, on the website when the ‘product’ is selected the ‘version’ ‘select’ box is populated:

'Declarations

Dim workspace As New NotesUIWorkspace

Dim uidoc As NotesUIDocument

Dim doc As NotesDocument

Dim product As String

Dim version As String

Dim ie As Variant

Dim objField As Variant



'Initialize variables so we can access the fields

Set uidoc = workspace.CurrentDocument

Set doc = uidoc.Document



version = doc.Version(0)

product = doc.Product(0)



'We're going to open a webpage so we initialize

'the internet explorer object

Set ie = CreateObject("InternetExplorer.Application")



'Open IE and navigate to the webpage

ie.Navigate "http://somesite.com/AddReport.aspx"



'The page may take a second to load, so we wait

'for it to finish

While(ie.Busy)

	Print "Loading webpage, please wait..."

	Sleep 1

Wend



'Show the page once it's done loading

ie.Visible = True



'Now we need to grab the fields off the webpage

'that we want to set the text/selection for, and then set it



'The 'Product' selection box

'Go through the options array and look for a match on product,

'when found set it to selected

Dim tempString As String

Set objField = ie.document.getElementById("ctl00_ctl00_SubNav_Content_ddlProduct")



For i = 0 To objField.options.length-1

	tempString = objField.options(i).innerHTML

	If tempString = product Then

		objField.options(i).selected = True

		Exit For

	End If

Next i



'The 'Version' selection box

'Go through the options array and look for a match on version

'when found set it to selected

Set objField = ie.document.getElementById("ctl00_ctl00_SubNav_Content_ddlVersion")



For i = 0 To objField.options.length-1

	tempString = objField.options(i).innerHTML

	If tempString = version Then

		objField.options(i).selected = True

		Exit For

	End If

Next i

Subject: Triggering HTML Events with LotusScript

Looks as if you are using COM to control Internet Explorer. Therefore what you need to do is to look at the object model for Internet Explorer and see if there is a method that does what you need.

Could you not achieve something similar using JavaScript and the onLoad event in the aspx???

You can certainly loop through the elements.

If you stick the product as an argument in the URL, e.g report.aspx?product=Blue widget the JavaScript would be able to pick it up from there

Subject: RE: Triggering HTML Events with LotusScript

I’m not sure what sort of method I’d be looking for in the object model for IE? I don’t think I really understand the object model beyond cycling through the elements of a webpage. I need something to simulate the actions… do you have any ideas? Like callJavascriptFunction or something.As to using Javascript and the onLoad event, I don’t believe that applies to this situation. I have no control over the external website, it’s under a different company’s control, so I can’t edit their webpage or their code at all. Anything I do to interact with the webpage has to be completely on my side of things, done with Domino.

I tried sticking the product as an argument in the URL just to see if anything would happen, but nothing changed doing that. I’m afraid I don’t have any experience with aspx, so I’m not sure how it works. What are the arguments that go up in the URL? Is it ‘website.aspx?elementId=option’ or what?

Subject: RE: Triggering HTML Events with LotusScript

You can simulate a mouse click via the click method (HTMLElement: click() method - Web APIs | MDN), but other than that I don’t know.

In any case, now that you have sorted out the basic mechanics of interacting with IE from Notes, you might get more response to these sorts of queries in a Microsoft DHTML discussion forum, since the techniques you are using are the same as you would use from VB, VBScript etc.