|
-
Nov 7th, 2008, 01:36 PM
#1
Thread Starter
Addicted Member
[RESOLVED] [2005] webBrowser selects
alright, I've downloaded Kleinma's code, studied over it, searched the forums, I don't see a way to set a combo box, the code in the codebank shows getting the value it is currently set to, which I had figured out.
Here's the section of the form I want to auto-fill/adjust:
Code:
<SELECT name=const_code>
<OPTION value=" ">Select Construction Code</OPTION>
<OPTION value=1>Proposed Construction</OPTION>
<OPTION value=2>Substantial Rehabilitation</OPTION>
<OPTION value=3>Under Construction</OPTION>
<OPTION value=4 selected>Existing Construction</OPTION>
<OPTION value=5>New Construction (Less than 1 Year)</OPTION>
</SELECT>
And I get the value using the following:
Code:
Me.WebBrowser1.Document.Forms("aac_form").All("const_code").GetAttribute("value")
Which doesn't give me the text, just the integer value, but I don't believe I actually need the text for my purposes, just the values anyhow.
Here's what I thought would work:
Code:
Me.WebBrowser1.Document.Forms("aac_form").All("const_code").SetAttribute("value",2)
But unlike the working textbox fill ins I have, this doesn't appear to do anything, not even throwing an exception.
Anyone know how to do this?
-
Nov 7th, 2008, 02:34 PM
#2
Re: [2005] webBrowser selects
You need to set the "selected" attribute of the child node in theat select node. For example, if you want to select the 3rd option (which has value=2), you do:
Code:
Me.WebBrowser1.Document.Forms("aac_form").All("const_code").Children(2).SetAttribute("selected", "selected")
Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
- Abraham Lincoln -
-
Nov 7th, 2008, 02:40 PM
#3
Thread Starter
Addicted Member
Re: [2005] webBrowser selects
Thank you that worked, now... in your code at the 2
Children(2)
what would be the 'name' if I wanted to go with the other overload?
-
Nov 7th, 2008, 02:54 PM
#4
Re: [2005] webBrowser selects
No, if you look at the html, you see that the option nodes do not have any name or id. That number 2 is the index of the child node. If you want to pick and option but you only know the display text or the value and not the index of the node, you have to loop thru the Children htmlElementCollection and test each element's value/innertext against your known value to find the right element. Once found, you set it "selected" attribute as shown.
Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
- Abraham Lincoln -
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
|