Cannot use placeholder {TOKEN:ATTRIBUTE_5} on question.

More
1 month 2 weeks ago #166889 by mfiora
mfiora created the topic: Cannot use placeholder {TOKEN:ATTRIBUTE_5} on question.
Hello,
i need to use {TOKEN:ATTRIBUTE_5} value in a question to condition answers. Any place holder, like {TOKEN:FIRSTNAME}, doesn't give back any value.
I'm on version 2.73.1+171220.

This is what i'm trying to do:
<script type="text/javascript" charset="utf-8">
 
   $(document).ready(function() {
 
     var gruppoPa = '{TOKEN:ATTRIBUTE_5}'.substring(7, 5).toUpperCase();
 
gruppoa = gruppoa.substring(7,5).toUpperCase();
 
       $('select[id^="answer"] option').each(function(i){
 
           if($(this).attr('value') && $(this).attr('value').substr(0, 2).toUpperCase() != gruppoa) {
               $(this).remove();
           }
       });
   });
 
   </script>

If this cannot be done how can i workaround it?

Thanks,

Please Log in or Create an account to join the conversation.

More
1 month 2 weeks ago #166892 by Joffm
Joffm replied the topic: Cannot use placeholder {TOKEN:ATTRIBUTE_5} on question.
Hi,
what I saw is
gruppoa = gruppoa.substring(7,5).toUpperCase();
"gruppoa" is not defined.
Maybe there is a typo and all variables are "gruppoa".
var gruppoPa = '{TOKEN:ATTRIBUTE_5}'.substring(7, 5).toUpperCase();
then gruppoPa is a 5 character string.

But then the next line which again tries to get a substring(7,5) out of a string which is only 5 characters long, will fail.

And in the rest of your script you use the not defined "gruppoa".

But without more knowledge what you are trying to do,...?
Can't you provide a sample of the problematic questions? *.lss

Best regards
Joffm

Please Log in or Create an account to join the conversation.

More
1 month 2 weeks ago #166897 by mfiora
mfiora replied the topic: Cannot use placeholder {TOKEN:ATTRIBUTE_5} on question.
Hello Joffm and thanks for your reply,
in the rendered page i cannot see the value of {TOKEN:ATTRIBUTE_5} so it's not a matter of typo. All i see is:
var gruppoa = '';

The script compares the first 2 letters in the answer code with 2 specific letters in the {TOKEN:ATTRIBUTE_5}. If they are not the same the answer is removed from the list.

If i set the gruppoa value manually the script works great.
You can see attached a .lsq file renamed to txt.

Thank you very much.
Attachments:

Please Log in or Create an account to join the conversation.

More
1 month 2 weeks ago - 1 month 2 weeks ago #166923 by Joffm
Joffm replied the topic: Cannot use placeholder {TOKEN:ATTRIBUTE_5} on question.
Hi,
now in your *.lsq the script is different from the first one.

lsq:
$(document).ready(function() {
 
      var gruppoa = '{TOKEN:ATTRIBUTE_5}';
      gruppoa = gruppoPa.substring(7,5).toUpperCase();

and

original:
$(document).ready(function() {
 
     var gruppoPa = '{TOKEN:ATTRIBUTE_5}'.substring(7, 5).toUpperCase();
 
gruppoa = gruppoa.substring(7,5).toUpperCase();

But:
What is "gruppoPa" in your *.lsq script?

Joffm
Last Edit: 1 month 2 weeks ago by Joffm.

Please Log in or Create an account to join the conversation.

More
1 month 2 weeks ago #166926 by mfiora
mfiora replied the topic: Cannot use placeholder {TOKEN:ATTRIBUTE_5} on question.
I'm sorry Joffm,
gruppoa and gruppoPa are the same variable. I deleted the P before posting here.
Beside that on the rendered page i see this:
<script>
 
   $(document).ready(function() {
 
      var gruppoa = "";
     gruppoa = gruppoa.split("_")[1];
     gruppoa = gruppoa.substr(0,2).toUpperCase();
 
       $('select[id^="answer"] option').each(function(i){
 
           if($(this).attr('value') && $(this).attr('value').substr(0,2).toUpperCase() != gruppoa) {
               $(this).remove();
           }
       });
   });
 
   </script>

I know this is still different. I'm trying to change to see if it works. I really think the problem is the {TOKEN:ATTRIBUTE_5} value not showing the "var gruppoa = " line.

Thank you very much. Your help is very appreciated.

Please Log in or Create an account to join the conversation.

More
1 month 2 weeks ago #166946 by mfiora
mfiora replied the topic: Cannot use placeholder {TOKEN:ATTRIBUTE_5} on question.
Hello,
just for testing i got rid of the javascript and only i left
Indicare la vostra scelta {TOKEN:ATTRIBUTE_5}
in the question field.

The attribute is still not visible.
Thanks.

Please Log in or Create an account to join the conversation.

More
1 month 2 weeks ago #166948 by tpartner
tpartner replied the topic: Cannot use placeholder {TOKEN:ATTRIBUTE_5} on question.
Can you attach a small test survey in .lss format?

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

Please Log in or Create an account to join the conversation.

More
1 month 2 weeks ago #166952 by mfiora
mfiora replied the topic: Cannot use placeholder {TOKEN:ATTRIBUTE_5} on question.
Hello tpartner,
i prepared the small test survey and then i tested it. It works there. :(
I mean, i can see the value of the {TOKEN:ATTRIBUTE_5} on the HTML source.
I thought it could be template-related so i set the same template on the real survey and still works.
So i suppose it's a problem on the real survey, which is huge.
Anyone can help me with that?
Thanks,

Please Log in or Create an account to join the conversation.

More
1 month 2 weeks ago #166956 by tpartner
tpartner replied the topic: Cannot use placeholder {TOKEN:ATTRIBUTE_5} on question.
Are you sure that the survey is non-anonymous?

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

Please Log in or Create an account to join the conversation.

More
1 month 2 weeks ago #166957 by mfiora
mfiora replied the topic: Cannot use placeholder {TOKEN:ATTRIBUTE_5} on question.
Hello tpartner,

Impostazioni dell'indagine: Le risposte a questa indagine NON sono anonime.

Survey settings: The answers for this survey are NOT anonymous.

Thanks,

regards,

Please Log in or Create an account to join the conversation.

More
1 month 2 weeks ago #166959 by mfiora
mfiora replied the topic: Cannot use placeholder {TOKEN:ATTRIBUTE_5} on question.
Hello,
here's another clue: i copied the survey structure to another survey.
Without activating it i clicked on "Run survey with this participant" and it worked.
Then i activated the survey and it didn't work.
Again i deactivated the survey, imported participants, took the survey and it worked.

What can i check?

Thanks,

Please Log in or Create an account to join the conversation.

More
1 month 2 weeks ago #166960 by Joffm
Joffm replied the topic: Cannot use placeholder {TOKEN:ATTRIBUTE_5} on question.
Hello, mfiora,

could you please send your test survey resp. the interesting part as *.lss

Joffm

Please Log in or Create an account to join the conversation.

More
1 month 2 weeks ago #166961 by mfiora
mfiora replied the topic: Cannot use placeholder {TOKEN:ATTRIBUTE_5} on question.
Here it is, i hope i've done it correctly.
Attachments:

Please Log in or Create an account to join the conversation.

More
1 month 2 weeks ago #166962 by mfiora
mfiora replied the topic: Cannot use placeholder {TOKEN:ATTRIBUTE_5} on question.
You should see opla_asti on the question. If you don't you have my same problem.

Please Log in or Create an account to join the conversation.

More
1 month 2 weeks ago - 1 month 2 weeks ago #166963 by Joffm
Joffm replied the topic: Cannot use placeholder {TOKEN:ATTRIBUTE_5} on question.
Hi, I created a participants table with the 5th attribute as "12345co89"

Activated the survey "not anonymous".

Then I get as "gruppoa" -> "CO"
and in the dropdown there are only the items with codes starting with "CO"


and a second with attribute "12345az89"





So it seems to work. I hope I understood correctly.

This seems to be really strange.

Hopefully Tony can investigate further.

All the best
Joffm
Attachments:
Last Edit: 1 month 2 weeks ago by Joffm.

Please Log in or Create an account to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now
Join our Newsletter!