invader_RMUK
asked on
VB Internet Controls - How to click a button with no name
Hi there, I know how to enter in text to a website, and then click a button with this code.
wbrInternet is my Web Browser im using in my program.
I then do this:
wbrInternet.document.all.i tem("textb oxname").v alue = "Test"
wbrInternet.document.all(" Button").c lick
and that works fine. Fine if the button you want to click HAS A NAME.
This is the following HTML code of a site I wish to enter text into, and click the button. the button doesnt have a name and so I cant click it.
<form method="get" action="index.php" name="searchForm">
<br>
<br>
<input name="text" type="text" size="30" autocomplete="off">
<select name="booke">
<option value="vb6">Visual Basic 6</option>
</select>
<input type="submit" value="Search Book">
</form>
How can I search that? I know I can do
wbrInternet.document.all.i tem("text" ).value = "Value I want"
but how do I do the click part?
Please help me.
Thanks
wbrInternet is my Web Browser im using in my program.
I then do this:
wbrInternet.document.all.i
wbrInternet.document.all("
and that works fine. Fine if the button you want to click HAS A NAME.
This is the following HTML code of a site I wish to enter text into, and click the button. the button doesnt have a name and so I cant click it.
<form method="get" action="index.php" name="searchForm">
<br>
<br>
<input name="text" type="text" size="30" autocomplete="off">
<select name="booke">
<option value="vb6">Visual Basic 6</option>
</select>
<input type="submit" value="Search Book">
</form>
How can I search that? I know I can do
wbrInternet.document.all.i
but how do I do the click part?
Please help me.
Thanks
Private Sub Command1_Click()
'WebBrowser1.Document.Form s("searchF orm").Item (2).Value = "Search Book"
Call WebBrowser1.Document.Forms ("searchFo rm").Item( 2).Click
End Sub
If the HTML is different for the Form (additional elements), then you may need to change (2) to the proper index.
'WebBrowser1.Document.Form
Call WebBrowser1.Document.Forms
End Sub
If the HTML is different for the Form (additional elements), then you may need to change (2) to the proper index.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Automating the submission of the form may cause problems if there are associated scripts (such as for OnClick event) for the Submit buttons. If the scripts do not execute, it may disrupt the data to be submitted. Another scenario may exist for forms that have different Submit-button elements as different values could be submitted.
See this post's accepted answer--instead of trying to click a button, try submitting the form that your items are on:
https://www.experts-exchange.com/questions/21387130/Web-pages-that-use-input-from-user-Part-2.html
wbrInternet.Document.Forms
And if that's no go, try looping through the elements/items and clicking each one, until you get the desired response. Then note the details/id of the one that worked.