How to click select component in a Web page using HTML DOM
Hi all,
Is there any idea to click the select component of an HTML page programitically
Here is the HTMT code
HTML Code:
<td width="83%" align=left nowrap><font face="Times New Roman, Times, serif">
<select name=cboPrimary size=1 onChange="RemoveOptionAndSubmit(cboSecondary)" style="width=350px;">
<option value="003" >ALLIED BANKING CORPORATION - $ BTB (USD )</option>
<option value="004" >ALLIED BANKING CORPORATION - PESO BTB (PHP )</option>
<option value="008" >ALLIED BANKING CORPORATION - PESO DTOD (PHP )</option>
<option value="052" >BANK OF THE PHILIPPINE ISLAND (USD )</option>
<option value="049" >BANK OF THE PHILLIPINE ISLAND (PHP )</option>
<option value="179" >EQUITABLE BANK / PCI (PHP )</option>
<option value="175" >METRO BANK (PHP )</option>
<option value="176" >METRO BANK - $ (USD )</option>
<option value="177" >PHILIPPINE NATIONAL BANK (PHP )</option>
<option value="178" >PHILIPPINE NATIONAL BANK - $ (USD )</option>
</select>
</font>
</td>
When one of bank is selected, the branches of that bank will be lsited.
Now I want to do this process programtically.
Here I used this code:
VB Code:
Dim BankIndex as Integer
Dim BankName as String
BankIndex = 5
browser.Document.getElementById("cboPrimary").selectedIndex = BankIndex
This code select the expected bank BANK OF THE PHILIPPINE ISLAND (USD )
But the page not lists the branch of this bank. It still remain wihout any action.
I also tried with the following code
VB Code:
browser.Document.getElementById("cboPrimary").click
But no effect
Is there any suggession to solve this problem
With regards,
Nasreen
Re: How to click select component in a Web page using HTML DOM
Use the HTMLObject Library
try this.. let me know
VB Code:
Dim HTML As HTMLDocument
Dim INP As HTMLSelectElement
Set HTML = webbrowser1.document
For Each INP In HTML.getElementsByTagName("select")
If INP.Name = "cboPrimary" Then
INP.Value = "052"
Exit For
End If
Next
Re: How to click select component in a Web page using HTML DOM
Thanks
The code is working same as the code I quoted before. Nothing more.
However I have got the idea to get the expected result by adding the following code also
VB Code:
browser.Document.getElementById("cboPrimary").onchange
This will trigger the click event for the select component.
With regards,
Nasreen
Re: How to click select component in a Web page using HTML DOM
So, is the problem resolved?
Re: How to click select component in a Web page using HTML DOM
Hi All,
How we can programitically click a button or link of a web page viewed in FRAMED web page.
I use for a web page without frame the following code :
VB Code:
Dim WithEvents objDocument As HTMLDocument
Private Sub browser_DownloadComplete()
Set objDocument = browser.Document
End Sub
This code work fine and without error.
But I want to do the same function in a web page with three frames, to control the mouse click programitically.
I used the the following code
VB Code:
Dim WithEvents objFrame As HTMLDocument
Private Sub browser_DownloadComplete()
Set objFrame = browser.Document.frames(0).Document.Frame
End Sub
But when execute the line (Set objFrame = browser.Document.frames(0).Document.Frame)
I got a runtime error saying Exception occurred.
I also changed that line as :
VB Code:
Set objFrame = browser.Document.frames.Item(2).Document
But I get another error saying Object or class does not support the set of events
Any idea to solve this problem or any idea to control the mouse click in a framed web page
With regards,
Nasreen