Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27349

Filling in textfields on web page

$
0
0
This is an explanation of what I am trying to do...

I want my app to obtain the user's search criteria, search craigslist with the user's criteria and then return the results of the craigslist search back to the user.

My GUI has 3 textfields (a search field, a maximum price field and a minimum price field) for the user to enter their "search criteria". My GUI also contains a search button which launches a WebBrowser object which navigates to craigslist (this part works just fine). I am having trouble filling in the user's search information from my GUI into the appropriate fields on the craigslist website itself. I have looked at the source code for craigslist and was trying to use GetElementsByTagName() but I don't think I was using it correctly. Here is the source code from craigslist that I was using this method for...

<span class="posterpicker"><b>owner</b><b> | </b><a href="../ctd" data-cat="ctd">dealer</a><b> | </b><a href="../cta" data-cat="cta">all</a></span></legend>
<div class="experimentalFeature">

</div>
<div id="searchtable">
<span class="searchgroup">
<span>
<input id="query" name="query" data-suggest="search" size="24" value="" placeholder="search" autocorrect="off" autocapitalize="off">
</span>
<input id="searchbtn" type="submit" value="search">
</span>

<span class="searchgroup">
price:
<input name="minAsk" class="min" size="5" placeholder="min" value="">
<input name="maxAsk" class="max" size="5" placeholder="max" value="">
</span>

<span class="searchgroup">
year:
<input name="autoMinYear" class="min" size="4" value="" placeholder="min">
<input name="autoMaxYear" class="max" size="4" value="" placeholder="max">
<input data-suggest="makemodel" placeholder="make/model" name="autoMakeModel" autocapitalize="off" autocorrect="off" size="15" value="">
</span>

and here is the code I was working with to try and put the user's search criteria into the appropriate textfields...

Dim elementCollection As HtmlElementCollection
elementCollection = WebBrowser1.Document.GetElementsByTagName("input")
For Each curElement As HtmlElement In elementCollection
Dim controlName As String = curElement.GetAttribute("name").ToString
If controlName = "query" Then
curElement.SetAttribute("Value", txtSearch.Text)

This explanation might be a little vague so if you need anymore information I will gladly try to help. If anyone has any suggestions on how to go about solving this, I would greatly appreciate it! :)

Viewing all articles
Browse latest Browse all 27349

Trending Articles