Random in value field

lokiys

Moderator
Регистрация
01.02.2012
Сообщения
4 769
Благодарностей
1 179
Баллы
113
That would be good if we could choose word ''random'' in value field as we can use in Nr. field.
There is many times when we should choose category or any other drop down menu value, but sometimes we do not know how many values is there.

Example very often there is what you choose County and then there appears City field and in every county city count is different. :-)

Cheers
 

nevadahsot

Client
Регистрация
27.04.2012
Сообщения
106
Благодарностей
5
Баллы
18
First set value,then get sth.
Loop until find it.
 

Вложения

lokiys

Moderator
Регистрация
01.02.2012
Сообщения
4 769
Благодарностей
1 179
Баллы
113

Hungry Bulldozer

Moderator
Регистрация
12.01.2011
Сообщения
3 441
Благодарностей
831
Баллы
113
Good one. There is workaround though
JavaScript:
var he = instance.ActiveTab.FindElementByAttribute("attributes to find here");
int optionsCount =he.GetChildren(false).Count;
if(optionsCount>0)
{
	var r  = new Random();
	he.SetAttribute("value",r.Next(0,optionsCount).ToString());
}
 
Последнее редактирование:
  • Спасибо
Реакции: lokiys

lokiys

Moderator
Регистрация
01.02.2012
Сообщения
4 769
Благодарностей
1 179
Баллы
113
Good one. There is workaround though
JavaScript:
var he = instance.ActiveTab.FindElementByAttribute("attributes to find here");
int optionsCount =he.GetChildren(false);
if(optionsCount>0)
{
	var r  = new Random();
	he.SetAttribute("value",r.Next(0,optionsCount).ToString());
}


Ошибка в действии "CS0029" "Cannot implicitly convert type 'ZennoLab.CommandCenter.HtmlElementCollection' to 'int'" в строке "int optionsCount = he.GetChildren(false);
"
 

Hungry Bulldozer

Moderator
Регистрация
12.01.2011
Сообщения
3 441
Благодарностей
831
Баллы
113
Changed
 
  • Спасибо
Реакции: bigcajones

Кто просматривает тему: (Всего: 1, Пользователи: 0, Гости: 1)