|
-
Jan 15th, 2014, 03:23 PM
#1
Thread Starter
Junior Member
Filling in textfields on web page
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!
-
Jan 16th, 2014, 12:39 AM
#2
Re: Filling in textfields on web page
try this:
Code:
WebBrowser1.Document.GetElementById("query").SetAttribute("value", "searchText")
WebBrowser1.Document.All.GetElementsByName("minAsk")(0).SetAttribute("value", "100.00")
WebBrowser1.Document.All.GetElementsByName("maxAsk")(0).SetAttribute("value", "101.00")
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Jan 16th, 2014, 11:39 AM
#3
Thread Starter
Junior Member
Re: Filling in textfields on web page
That seemed to work, thank you.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|