Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

detect token lenght character in a question code

  • startx25
  • startx25's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
10 years 6 months ago #99720 by startx25
Hi,

I don't know why but this code doesn't work

<script type="text/javascript">
var mytok;
if({TOKEN}.length < 4){
mytok1 = "smaltoken";
}else{
mytok2 = {TOKEN};
}

</script>

With javascript in a question code,
I am trying to identify some token who have ony 4 characters,
but this condition deosn't match...

thank you for any help
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
10 years 6 months ago - 10 years 6 months ago #99754 by tpartner
Try something like this:
Code:
<script type="text/javascript">
  var mytok;
  var token = "{TOKEN:ATTRIBUTE_1}";
  if(token.length < 4){
    mytok1 = "smaltoken";
  }
  else{
    mytok2 = token;
  }
 
</script>

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 10 years 6 months ago by tpartner.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose