Welcome, Guest
Username: Password: Remember me

TOPIC: Display Random Number

Display Random Number 3 months 1 week ago #111605

Hi,

Would it be possible to display a random number in a given range? For example, if LimeSurvey is being used out in the field, I would like the ability to have it display a number between 1 and the total number of people in the area (entered by me of course) to select which person to survey.
The administrator has disabled public write access.

Display Random Number 3 months 1 week ago #111612

  • holch
  • holch's Avatar
  • NOW ONLINE
  • LimeSurvey Team
  • Posts: 2952
  • Thank you received: 379
  • Karma: 124
You can use the Expression Manager and the function: rand(1,100) for having a random number between 1 and 100.
Have a look at the manual! It is a really valuable source for information. Here some helpful links:
Manual (EN) | Question Types | Question Attributes | Workarounds

If you found this answer helpful and it saved you some time please consider a donation to the project to keep Limesurvey going!
The administrator has disabled public write access.
The following user(s) said Thank You: AudioMan612

Display Random Number 3 months 1 week ago #111614

Thanks! Now to figure out why it's not working with one of my templates (or can you only do expressions like this with certain types of questions?).


RandError.png
The administrator has disabled public write access.

Display Random Number 3 months 1 week ago #111619

  • holch
  • holch's Avatar
  • NOW ONLINE
  • LimeSurvey Team
  • Posts: 2952
  • Thank you received: 379
  • Karma: 124
Did you have a look at the manual how to implement things with Expression Manager? There are some examples of code. I would say, the most obvious thing is that you can't just put the function into the source code like this, because LS doesn't know that it is an equation.

Equations in Expression Manager are usually between { and }.

Have a look at the link about Expression Manager. There are a lot of good examples.

Here is another example: www.limesurvey-consulting.com/how-to-ran...a-limesurvey-survey/

Regarding the problem with span, I guess you should have no space between "<" and "span".
Have a look at the manual! It is a really valuable source for information. Here some helpful links:
Manual (EN) | Question Types | Question Attributes | Workarounds

If you found this answer helpful and it saved you some time please consider a donation to the project to keep Limesurvey going!
The administrator has disabled public write access.

Display Random Number 3 months 1 week ago #111629

  • tpartner
  • tpartner's Avatar
  • NOW ONLINE
  • LimeSurvey Team
  • Posts: 4362
  • Thank you received: 827
  • Karma: 381
The <span> element is inserted when there is an error in Expression Manager.
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.106 seconds
Donation Image