Dropdownlist

Joined
Jun 29, 2010
Messages
41
Reaction score
41
For some reason I'm having issues setting the value of a dropdownlist through the following code:

WebBrowser1.Document.GetElementById("dobDay").SetAttribute("value",1)

This is html that coresponds to it:
<div class="ipt"><label class="hidden-label" for="dobDay">Day</label></div>
<input type="hidden" name="wlw-select_key:{actionForm.dobDay}OldValue" value="true">
<select name="wlw-select_key:{actionForm.dobDay}" id="dobDay" class="dobDay"><option value="">Day</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option></select>
<script language="JavaScript" type="text/JavaScript">
<!--
netui_tagIdNameMap.dobDay="wlw-select_key:{actionForm.dobDay}"
-->
</script>


I've never had this problem before so I'm kind of braindead on this. I thought may the javascript that it references was an issue but I cant tell. Any help?
 
See if putting the new value in quotes can solve your problem. It is expecting a string, not a numeric value. Or the Name attribute instead of the ID.

Code:
WebBrowser1.Document.All.Item("wlw-select_key:{actionForm.dobDay}").SetAttribute("value", "1")
 
Nope...Still no dice. The odd thing is when I run a loop through all of the elements on the page Ids everyone comes up fine except this combo box. It has a name and an id in the html but for some reason when you try and call it and set its value my program thinks it dosent have an id........

Heres the entire page
https://new.aol.com/productsweb/?promocode=827692&ncid=txtlnkuswebr00000073
 
So I cant figure this out....it has no ID...when you loop through all the elements in the page it dosent have an ID...but on the HTML page it does.....I also tried the following with no look.

I tried setting the focus on the field above the drop down box
then I tried sendkey with Tab and Sendkey with down for the down arrow thinking I could change the value of the box that way.

Anyway know anyway I can set the value of these stupid combox boxes. Id even go for a mouse click on the box and then a down key but I doubt thats possible. Any ideas??
 
I really have no experience with javascript but it seems you need to invoke the script at the bottom that is setting the value: netui_tagIdNameMap.dobDay="wlw-select_key:{actionForm.dobDay}" and pass the desired value.

Here is how to invoke scripts from vb (the comments may help too):
dotnetcurry.com/ShowArticle.aspx?ID=194

It seems that the function is getting the element by its ID (dobDay) and setting it's value to the selected string which is somehow contained in the '{actionForm.dobDay}'.

Maybe if you can figure out what wlw-select_key is (an index?) you might be able to pass that.
 
tried that too with no luck...this stupid combo box is killing me
 
Code:
For Each element As HtmlElement In WebBrowser1.Document.All("[FONT=Consolas][SIZE=2][COLOR=#008000][FONT=Consolas][SIZE=2][COLOR=#008000][FONT=Consolas][SIZE=2][COLOR=#008000]dobDay[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT]").GetElementsByTagName("option")
    If element.GetAttribute("value") = "[SIZE=2][COLOR=DarkGreen]1[/COLOR][/SIZE]" Then
         element.SetAttribute("selected", True)
         Exit For
    End If
Next
 
Last edited:
Back
Top