Welcome to the LimeSurvey Community Forum

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

Is it possible to pass the token in the url and store as a hidden field?

  • dataguru
  • dataguru's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
12 years 7 months ago #64263 by dataguru
I added it to both question groups, altered it just a little and it works perfectly!
Code:
<script type="text/javascript" charset="utf-8">
 
  $(document).ready(function() {
 
    // Find the survey ID
    if($('input#fieldnames').length != 0) {
      var fieldNames = $('input#fieldnames').attr('value');
      var tmp = fieldNames.split('X');
      var sID = tmp[0];
    }
 
    // Insert a new div after the progress bar
    $('<div id="optOutLink" />').insertBefore('#progress-wrapper');
 
    // Style the new div
    $('#optOutLink').css({
      'text-align':'center'
    });
 
    // Insert opt out url in the new div
    $('#optOutLink').html('<P><a href="optout.php?lang=en&amp;sid='+sID+'&amp;token={TOKEN}">Click here to opt out of this survey.</a></p><br>');
 
  });
 
</script>

Thanks again for your assistance!

FYI, I think our IT department is going to start using LS as well. Now I just have to try and figure out how to get a donation made to help support this project.

Betty
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
12 years 7 months ago #64283 by tpartner
You're welcome.

You may want to change <P> to <p>. IE sometimes gets confused by uppercase tags.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • dataguru
  • dataguru's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
12 years 7 months ago #64291 by dataguru
The topic has been locked.
More
7 years 5 months ago #142180 by f1refly
I am trying to do this same thing with an opt out link. How would it be accomplished in the current version (2.52?)

I have copied the javascript to the source description of my group. But I don't see a link. I think that there is no longer a #progress-wrapper. I would be happy with the opt out link in the description.

Any pointers?
The topic has been locked.
More
7 years 5 months ago #142197 by jelo

f1refly wrote: I am trying to do this same thing with an opt out link. How would it be accomplished in the current version (2.52?)

To add your post to an old and long thread can minimize the chance for answers.
Nobody likes to dig through old stuff to grasp the status quo of the discussion.

If you just need a URL with a token on every page of the survey you can try to add the link directly to the template.
The token placeholder should be possible to add to the template as well. Haven't tested it on my own.
If you need the URL only on certain pages it depends on the position of the URL which way to go.

The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
The following user(s) said Thank You: f1refly
The topic has been locked.
More
7 years 5 months ago #142203 by f1refly
Thanks for the reply. I thought I was being efficient by adding it to a post about the same thing but I certainly see what you mean!
I have managed to add the link (without the token) to the template because I do want it on every page. The TOKEN replacement variable doesn't work though. I'm not sure if it just doesn't work in the templates or if it is because my survey is anonymous. Could be both. I'll start a new thread about this.

Thanks again.
The topic has been locked.
  • Mazi
  • Mazi's Avatar
  • Offline
  • Official LimeSurvey Partner
  • Official LimeSurvey Partner
More
7 years 5 months ago #142225 by Mazi

f1refly wrote: I'm not sure if it just doesn't work in the templates or if it is because my survey is anonymous. Could be both. I'll start a new thread about this.

If the survey is anonymous, the TOKEN replacements will probably be turned off. Same for variables like {TOKEN:ATTRIBUTE_1} and similar.
This is to ensure anonymity.

Best regards/Beste Grüße,
Dr. Marcel Minke
Need Help? We offer professional Limesurvey support: survey-consulting.com
Contact: marcel.minke(at)survey-consulting.com
The following user(s) said Thank You: f1refly
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose