Hello @altkmv.

The piece of code: `Math.floor (Math.random () * 10);`

is correct, even if you are using our plugin it could be implemented as `FLOOR(RANDOM()*10)`

without the Math object, but with your description it is not clear the way you are assigning the random number to the fields, or the way you are using this number.

Please, send me the link to the webpage where the form is inserted and describe the process.

Best regards.

Thread Starter
altkmv
(@altkmv)

Here is the test page: https://irongeneration.ru/akcii . I want to understand the principle and do it right

Hello @altkmv,

The process was not implemented as should, you cannot use the button as an operand in the equation, because the buttons don’t have an onchange event. So, the equation would be as follows:

1. Insert a hidden field in the form, I’ll call it the fieldname123

2. Edit the onclick event of the button as follows:

```
jQuery('[id*="fieldname123_"]').val(FLOOR(RANDOM()*10)).change();
```

3. Finally, edit the equation associated to the calculated field to use the hidden field inserted in the first step.

and that’s all.

Note that the fields’ names are generated dynamically, so, in the previous code you should use the corresponding field’s name.

Best regards.

Thread Starter
altkmv
(@altkmv)

Thanks alot!

Whether correctly I understood, I create a calculated field. By this equation I gain the value this calculated field and if the value is 1, then I output the field 1, the value 2 – the field 2, etc.?

Apparently, I again understand everything is not entirely correct, because the display of the fields does not work (as if the field is always 0).

Hello @altkmv,

I’m sorry, I don’t understand what do you mean with the fields to display, but if you want to display some fields based on the equation’s results, you simply should defined dependencies in the settings of calculated field.

By the way, I think that would be better if you move the code that generate the random number directly to the equation, run this code in the onclick event only for assigning the generated number to the calculated field, has no sense. In this case you can include the piece of code that generates the random number as part of the equation:

```
(function(){
return FLOOR(RANDOM()*10);
})()
```

Best regards.