Random select drop down menu imacros

喜夏-厌秋 提交于 2020-01-05 07:50:15

问题


I am trying to figure out how to randomized a drop down menu in iMacros.

This is the current script.

TAG POS=1 TYPE=SELECT FORM=ACTION:/es/crear-tu-blog/ ATTR=NAME:domain CONTENT=$activos-blog.net

There are like 30 alternative for this drop down menu, I want to make it select a random alternative. How can i do this?.


回答1:


You need something like this:

SET !VAR1 EVAL("var randomDomain=Math.floor(Math.random()*30 + 1); randomDomain;")
TAG POS=1 TYPE=SELECT FORM=ACTION:/es/crear-tu-blog/ ATTR=NAME:domain CONTENT=%{{!VAR1}}

Where 30 is the number of elements in the drop down menu, and the % indicates we are selecting the option by its value.

For example, I'm expecting the option to be:

<option value="12">activos-blog.net</option>

If the value is a string, then you should select the option by its index, using #.




回答2:


You can select the dropdown menu like this.

This is the current script.

TAG POS=1 TYPE=SELECT FORM=ACTION:/es/crear-tu-blog/ ATTR=NAME:domain CONTENT=#5

In some cases, I saw %5 so I am not sure is it % or # before the number. The number 5, in this case, is just an example.

Here is what it says on iMacros.

http://wiki.imacros.net/TAG

Scroll down to where it says dropdown menu.

The next step is to create a random number with use of JavaScript. On the link below, you can get the functions for that purpose.

Generating random whole numbers in JavaScript in a specific range?

After you've mastered that the next step is to implement it in iMacros. You have to use JavaScript scripting.

var macro;

macro ="CODE:";
macro +="TAG POS=1 TYPE=SELECT FORM=ACTION:/es/crear-tu-blog/ ATTR=NAME:domain CONTENT=#{{number}}";


iimSet("number",some_random_number)
iimPlay(macro)


来源:https://stackoverflow.com/questions/15802295/random-select-drop-down-menu-imacros

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!