Check out the LimeSurvey source code on GitHub!
Welcome, Guest
Username: Password:

TOPIC: detect token lenght character in a question code

detect token lenght character in a question code 3 years 2 weeks ago #99720

  • startx25
  • startx25's Avatar
  • Offline
  • Senior Lime
  • Posts: 50
  • Karma: 0
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 administrator has disabled public write access.

detect token lenght character in a question code 3 years 2 weeks ago #99754

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 6321
  • Thank you received: 1407
  • Karma: 547
Try something like this:
<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: 3 years 2 weeks ago by tpartner.
The administrator has disabled public write access.
Time to create page: 0.272 seconds
Imprint                   Privacy policy         General Terms & Conditions         Revocation information and revocation form