Answer the question
In order to leave comments, you need to log in
C# WebBrowse filling select with random?
I made it so that I would choose from select , but I need to fasten the random from 1 to 15 example.
Selection code
foreach (HtmlElement element in webBrowser1.Document.All)
{
if (element.GetAttribute("name") == "myselect")
{
element.Children[0].SetAttribute("selected", "false");
element.Children[1].SetAttribute("selected", "false");
element.Children[2].SetAttribute("selected", "false");
element.Children[3].SetAttribute("selected", "false");
element.Children[4].SetAttribute("selected", "false");
element.Children[0].SetAttribute("selected", "false");
element.Children[5].SetAttribute("selected", "true");
}
}
Answer the question
In order to leave comments, you need to log in
As I understand it, you are unfamiliar with cycles. Well, okay ... At the very beginning of the function, we write instruction
A inside the cycle 1 line
element.Children[r.Next(0,element.Children.Count)].SetAttribute("selected", "true");
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question