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