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.item("textboxname").value = "Test"
      wbrInternet.document.all("Button").click

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.item("text").value = "Value I want"

but how do I do the click part?

Please help me.

Thanks
invader_RMUKAsked:
Who is Participating?
 
edwardiiiConnect With a Mentor Commented:
Slight modification--to submit "searchForm", which is equivalent to clicking the "Submit" button (if so labelled):  
 
      wbrInternet.Document.Forms("searchForm").Submit
0
 
edwardiiiCommented:
Hi, invader_RMUK.

See this post's accepted answer--instead of trying to click a button, try submitting the form that your items are on:

http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_21387130.html

     wbrInternet.Document.Forms("login_form").Submit

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.
0
 
zzzzzoocCommented:
Private Sub Command1_Click()
    'WebBrowser1.Document.Forms("searchForm").Item(2).Value = "Search Book"
    Call WebBrowser1.Document.Forms("searchForm").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.
0
 
zzzzzoocCommented:
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.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.