Question select radiobutton

gixslayer

Member
Joined
Nov 8, 2008
Messages
19
Programming Experience
Beginner
Hey,

I have a site, which I need to select a radiobutton through code.

This is the code from the site
VB.NET:
					<input type="Radio" class="radio" name="c" value="2" checked /> Versterking<br>
					<input type="Radio" class="radio" name="c" value="3"  /> Aanval<br>
					<input type="Radio" class="radio" name="c" value="4"  /> Overval				</td>

Right now I'm trying this code, but it won't work.

VB.NET:
Mainform.WebBrowser2.Document.All.GetElementsByName("c").Item(0).SetAttribute("value", 3)

I want to be able to set the value from 2-4, but how can i do this?
Thanks anyway,
gixslayer
 
Wrong forum, thread moved

Why don't you use the asp:OptionButton instead of an input radio button, then in the code behind you can simply refer to it by name.
 
I think, it's not "his" website, but he tries to code a kind of bot for a webpage. The bot has to select the radiobuttons etc.

googling for the words in the buttons, I might assume he plays "travian" ... ?
 
I think, it's not "his" website, but he tries to code a kind of bot for a webpage. The bot has to select the radiobuttons etc.

googling for the words in the buttons, I might assume he plays "travian" ... ?

Wel yea, kinda just a little experience i'm trying. Never really made a bot or such for a browsergame. Something else lol. Having no problems at all, expect selecting the radio button for attack type. I know the control name is "c" and value 2-3-4, but when i set the value, the radiobutton wont change.
 
ok got it to work now using this code
VB.NET:
Mainform.WebBrowser2.Document.All.GetElementsByName("c").Item(Type).SetAttribute("checked", "True")

with type being 0,1 or 2.
 
Back
Top