Welcome, Guest
Username: Password: Remember me

TOPIC: detect token lenght character in a question code

detect token lenght character in a question code 1 year 1 week 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 1 year 5 days ago #99754

  • tpartner
  • tpartner's Avatar
  • NOW ONLINE
  • LimeSurvey Team
  • Posts: 4183
  • Thank you received: 785
  • Karma: 359
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.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
Last Edit: 1 year 5 days ago by tpartner.
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.111 seconds
Donation Image