Click here to Skip to main content
15,887,304 members
Please Sign up or sign in to vote.
1.00/5 (5 votes)
See more:
hi,
select item in dropdown(webbrowser)?
c#

HTML
<span class="label">Select date</span>
<select name="starting_date">
		<option value="20130815" selected="">The soonest open time slots</option>
<option value="20130815">Thursday, 15 August 2013</option>
<option value="20130818">Sunday, 18 August 2013</option>
<option value="20130819">Monday, 19 August 2013</option>
<option value="20130820">Tuesday, 20 August 2013</option>
<option value="20130821">Wednesday, 21 August 2013</option>
<option value="20130822">Thursday, 22 August 2013</option>
<option value="20130825">Sunday, 25 August 2013</option>
<option value="20130826">Monday, 26 August 2013</option>
<option value="20130827">Tuesday, 27 August 2013</option>
<option value="20130828">Wednesday, 28 August 2013</option>
	</select>
Posted
Comments
Richard C Bishop 14-Aug-13 12:02pm    
And....what?
samadblaj 14-Aug-13 13:25pm    
select index (not found id) :
HtmlElement hField = webBrowser1.Document.GetElementById("service_id"); //dropdownlist
hField.SetAttribute("selectedIndex", "1");//select index
Silvabolt 14-Aug-13 16:47pm    
What technology are you using? WinForm? ASP.NET? Anyways your dropdownlist doesn't have an ID, so service_id definitely won't get you any elements.
samadblaj 15-Aug-13 2:46am    
using WinForm.
Ayodeji Oluwatomiwo 14-Aug-13 16:54pm    
Guess that should be HTML and ur question isn't clear enough.

1 solution

change the name to Id so that you can invoke from java script.



Java Script :
starting_date.selectedIndex = 2
alert(starting_date.value)

//using jquery
alert($('#starting_date').val());


I have tried the same in the JSFiddle

http://jsfiddle.net/fDWsK/[^]
 
Share this answer
 
Comments
samadblaj 15-Aug-13 2:45am    
windows appliction:
example code | this not id :
HtmlElement hField = webBrowser1.Document.GetElementById("service_id"); //dropdownlist
hField.SetAttribute("selectedIndex", "1");//select index

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900