Hi guys,
I have this very specific scenario that requires a randomly generated number according to a text entry. Here's a brief description:
Screen 1: _How much do you expect to sell this item?_ [positive number-only entry], let's say respondent enters 5000
Screen 2: _Buyer proposes to buy your item for_ [a randomly generated number between 0 and the entered number in Screen 1] (so between 0 and 5000). _Would you accept the offer_?
I can't figure out how to generate the number in Screen 2. I tried random number generation in piped text but it didn't work.
Thanks a lot in advance!!
Page 1 / 1
The problem is probably that you can't nest pipes. You can do it in JavaScript:
```
var randNum = (parseInt("${q://QID1/ChoiceTextEntryValue}") * Math.random()).toFixed(0);
```
```
var randNum = (parseInt("${q://QID1/ChoiceTextEntryValue}") * Math.random()).toFixed(0);
```
TomG, thank you! I tried this in various what but somehow didn't get it to show up correctly. Could you please let me know how I can insert exactly this in between _Buyer proposes to buy your item for_ [blank] _Would you accept the offer?_
> @vinhpham194 said:
> TomG, thank you! I tried this in various what but somehow didn't get it to show up correctly. Could you please let me know how I can insert exactly this in between _Buyer proposes to buy your item for_ [blank] _Would you accept the offer?_
>
html:
```
Buyer proposes to buy your item for <span class="randNum"></span>. Would you accept the offer?
```
JS:
```
jQuery("#"+this.questionId+" .randNum").html(randNum);
```
> TomG, thank you! I tried this in various what but somehow didn't get it to show up correctly. Could you please let me know how I can insert exactly this in between _Buyer proposes to buy your item for_ [blank] _Would you accept the offer?_
>
html:
```
Buyer proposes to buy your item for <span class="randNum"></span>. Would you accept the offer?
```
JS:
```
jQuery("#"+this.questionId+" .randNum").html(randNum);
```
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.