To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here
VBForums  

VB Wire News
MSDN Subscribers: Download the VS 2010 Release Candidate
MSDN Subscribers: Download the VS 2010 Release Candidate
Sell Your Code and Make Money?
Creating your own Tetris game using VB.NET
Article :: Improving Software Economics, Part 4 of 7: Top 10 Principles of Iterative Software Management



Go Back   VBForums > Visual Basic > Visual Basic 6 and Earlier

Reply Post New Thread
 
Thread Tools Search this Thread Display Modes
Old Feb 12th, 2007, 12:52 PM   #1
nasreen
Lively Member
 
Join Date: Apr 05
Posts: 69
nasreen is an unknown quantity at this point (<10)
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:
  1. Dim BankIndex as Integer
  2. Dim BankName as String
  3. BankIndex  =  5
  4. 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:
  1. browser.Document.getElementById("cboPrimary").click

But no effect

Is there any suggession to solve this problem

With regards,
Nasreen

Last edited by nasreen; Feb 12th, 2007 at 12:54 PM. Reason: Spell corret
nasreen is offline   Reply With Quote
Old Feb 12th, 2007, 01:27 PM   #2
Static
eltiT resU motsuC
 
Static's Avatar
 
Join Date: Oct 00
Location: Rochester, NY
Posts: 9,228
Static is a glorious beacon of light (400+)Static is a glorious beacon of light (400+)Static is a glorious beacon of light (400+)Static is a glorious beacon of light (400+)Static is a glorious beacon of light (400+)Static is a glorious beacon of light (400+)
Re: How to click select component in a Web page using HTML DOM

Use the HTMLObject Library
try this.. let me know
VB Code:
  1. Dim HTML As HTMLDocument
  2.     Dim INP As HTMLSelectElement
  3.     Set HTML = webbrowser1.document
  4.     For Each INP In HTML.getElementsByTagName("select")
  5.         If INP.Name = "cboPrimary" Then
  6.             INP.Value = "052"
  7.             Exit For
  8.         End If
  9.     Next
__________________
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
Static is offline   Reply With Quote
Old Feb 13th, 2007, 01:33 PM   #3
nasreen
Lively Member
 
Join Date: Apr 05
Posts: 69
nasreen is an unknown quantity at this point (<10)
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:
  1. browser.Document.getElementById("cboPrimary").onchange

This will trigger the click event for the select component.

With regards,
Nasreen
nasreen is offline   Reply With Quote
Old Feb 13th, 2007, 01:35 PM   #4
Hack
Super Moderator
 
Hack's Avatar
 
Join Date: Aug 01
Location: Sterling Heights, Michigan
Posts: 52,309
Hack has much to be proud of (1500+)Hack has much to be proud of (1500+)Hack has much to be proud of (1500+)Hack has much to be proud of (1500+)Hack has much to be proud of (1500+)Hack has much to be proud of (1500+)Hack has much to be proud of (1500+)Hack has much to be proud of (1500+)Hack has much to be proud of (1500+)Hack has much to be proud of (1500+)Hack has much to be proud of (1500+)
Re: How to click select component in a Web page using HTML DOM

So, is the problem resolved?
__________________
Please use [Code]your code goes in here[/Code] tags when posting code.
When you have received an answer to your question, please mark it as resolved using the Thread Tools menu.
Before posting your question, did you look here?
Got a question on Linux? Visit our Linux sister site.
I dont answer coding questions via PM or EMail. Please post a thread in the appropriate forum.

Creating A Wizard In VB.NET
Modifications Required For VB6 Apps To Work On Vista
Paging A Recordset
What is wrong with using On Error Resume Next
IT professionals freelancer site. Register today to find coders, or offer your services for available freelance projects!
Microsoft MVP 2005/2006/2007/2008/2009
Hack is offline   Reply With Quote
Old Mar 4th, 2007, 03:27 AM   #5
nasreen
Lively Member
 
Join Date: Apr 05
Posts: 69
nasreen is an unknown quantity at this point (<10)
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:
  1. Dim WithEvents objDocument As HTMLDocument
  2.  
  3. Private Sub browser_DownloadComplete()
  4. Set objDocument = browser.Document
  5. 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:
  1. Dim WithEvents objFrame As HTMLDocument
  2. Private Sub browser_DownloadComplete()
  3. Set objFrame = browser.Document.frames(0).Document.Frame
  4. 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:
  1. 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

Last edited by nasreen; Mar 4th, 2007 at 08:43 AM.
nasreen is offline   Reply With Quote
Reply

Go Back   VBForums > Visual Basic > Visual Basic 6 and Earlier


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 01:20 PM.




To view more projects, click here

Acceptable Use Policy


The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.